(node:6868) DeprecationWarning:`node –inspect –debug-brk`已被弃用

我第一次遇到这样的错误,如果我在这里没有注意到任何重要的因素,请原谅我。 运行我的代码时得到的完整错误是:

(node:10812) [DEP0062] DeprecationWarning: `node --inspect --debug-brk` is deprecated. Please use `node --inspect-brk` instead. 

如下所示:

在这里输入图像描述

它还突出显示了这一行代码:

 return new Script(code, options); 

如下所示:

在这里输入图像描述

这是我运行的node.js的版本,如nvm所示。

 C:\Users\jonat>nvm install latest Version 8.4.0 is already installed. 

我昨天运行VS安装程序,所以它是最新的。

这些是我正在使用的模块:

 const express = require("express"), mongoose = require("mongoose"), passport = require("passport"), bodyParser = require("body-parser"), LocalStrategy = require("passport-local"), passportLocalMongoose = require("passport-local-mongoose"), math = require("mathjs"); 

他们已经通过npm安装,我最近在这里运行.npm update他们显示在inheritance人文件目录:

在这里输入图像描述

在这里,不同的设置被改变,将会被使用的variables被设置:

 const app = express(); const uri = 'mongodb://localhost/MathsWebsite', options = { useMongoClient: true }; mongoose.Promise = global.Promise; mongoose.set('debug', true); app.set('view engine','ejs'); app.use(bodyParser.urlencoded({extended:true})); app.use(require("express-session")({ secret:"fanatical beaver", resave: false, saveUninitialized: false })); app.use(passport.initialize()); app.use(passport.session()); passport.use(new LocalStrategy(user.authenticate())); passport.serializeUser(user.serializeUser()); passport.deserializeUser(user.deserializeUser()); 

值得注意的是我可以使用以下代码运行:

 C:\Users\jonat\Documents\GitHub\MathsSite\MathsWebsite>node server.js --no-deprecation 

然后导致链接的错误( https://hastebin.com/lajotaqifo.rb )如下所示:

在这里输入图像描述

seed.js函数位于代码的底部,如下所示:

 mongoose.connect(uri, options) .then(() => seedDB) .then(() => app.listen(process.env.PORT, process.env.IP, function () { console.log("Server started"); })) .catch(error => console.log("error")); 

如图所示导入:

 const seedDB = require("./seed"); 

如图所示导出:

 async function seedDB() {...} module.exports = seedDB; 

并位于如下所示的文件目录中:

在这里输入图像描述

我相信这个错误是不相关的弃用问题,虽然我认为最好的我提到它。 虽然我相信我可以绕过这个问题,正如我已经表明,我认为这是不可接受的长期来看,如果任何人都可以提供解决这个问题,甚至只是在正确的方向指向我将不胜感激。

(以防万一这是必要的从server.js ( https://hastebin.com/ibuweyaxes.js )和seed.js ( https://hastebin.com/ibuweyaxes.js )的完整代码的链接)在hastebin)此外,会注意到由于我缺乏这方面的知识,我可能已经包括无用的东西或未能包括有用的东西。

问题是在第343行的Seed.js文件中,因为错误信息正确指出,所以不能在asynchronous函数之外使用await。 虽然SeedDB可能是asynchronous函数,但是await代码实际上在catch语句中,那么为了不错误,必须声明为asynchronous函数。

从你的pastebin剪下来的代码如下所示:

 }).then(() => { 

所以只需在箭头函数之前添加asynchronous, 然后就像我在下面做的那样。

 }).then(async () => { 

这就是完整的诺言:

 Promise((resolve, reject) => { examboardData.forEach(function (examSeed) { examBoard.create(examSeed, function (err, exam) { console.log("Creating new examboard"); if (err) { console.log("Could not create new examboard\n" + err); } else { console.log("Created examboard"); exams.push(exam); } }); }); questionData.forEach(function (questionSeed) { question.create(questionSeed, function (err, question) { if (err) { console.log("Could not create new question\n" + err); } else { console.log("Created question"); questions.push(question); } }); }); }).then(async () => { var topicIncrementor = 0; for (let question of questions) { for (var i = 0; i < exams.length; i++) { for (var t = 0; t < exams[i].modules.length; t++) { for (var q = 0; q < exams[i].modules[t].topics.length; q++) { exams[i].modules[t].topics[q].questions.push(question); topicIncrementor++; } topicIncrementor = 0; } await exams[i].save(); } } });