微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

javascript – (node:71307)[DEP0079]弃用警告

尝试更新MongoDB文档获取弃用警告为

(node:71307) [DEP0079] DeprecationWarning: Custom inspection function
on Objects via .inspect() is deprecated

节点版本v10.5.0,
db版本v3.6.5,
猫鼬版mongoose@4.1.12

Campground.findById(campgroundId,function(err,campground){
    if(err){
        console.log(err);
    } else {
        console.log(campground.celebrity);
        Celebrity.create(celebrityData,celebrity){
            if(err){
                console.log(err);
            } else {
                //save comment
                celebrity.save();
                campground.celebrity.push(celebrity);
                campground.save();
                console.log(celebrity);
                //req.flash('success','Created a comment!');
            }
        });
    }
});

解决方法

你不必担心这个错误,这是猫鼬警告.实际上Mongoose使用inspect()来调试输出.他们将更新它可能在节点12.x之前.目前使用它是安全的.

没什么好担心的.

检查此信息.
https://nodejs.org/api/deprecations.html#deprecations_dep0079_custom_inspection_function_on_objects_via_inspect

DEP0079: Custom inspection function on Objects via .inspect()# Type:
Runtime

Using a property named inspect on an object to specify a custom
inspection function for util.inspect() is deprecated. Use
util.inspect.custom instead. For backward compatibility with Node.js
prior to version 6.4.0,both may be specified.

如果您想了解更多细节,请参阅此内容.这正在进行中.警告将在节点10中出现

https://github.com/Automattic/mongoose/issues/6420

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐