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

前端之家收集整理的这篇文章主要介绍了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

猜你在找的JavaScript相关文章