为什么我无法启动节点/快速服务器?

时间:2020-07-05 18:39:38

标签: node.js mongodb express npm

嗨,我是node / express的新手,我正在关注mdn(https://developer.mozilla.org/en-US/docs/Learn/Server-side/Express_Nodejs/routes)上的快速教程。我添加了路由和虚拟控制器功能,并准备启动服务器进行测试,但是出现以下错误:

C:\test-node\libraryapp\express-locallibrary-tutorial>SET DEBUG=express-locallibrary-tutorial:* & npm 
run 
devstart

> express-locallibrary-tutorial@0.0.0 devstart C:\test-node\libraryapp\express-locallibrary-tutorial
> nodemon ./bin/www

[nodemon] 2.0.4
[nodemon] to restart at any time, enter `rs`
[nodemon] watching path(s): *.*
[nodemon] watching extensions: js,mjs,json
[nodemon] starting `node ./bin/www`
C:\test-node\libraryapp\express-locallibrary-tutorial\app.js:16
var mongoDB = mongodb+srv://user:password@cluster0.d7lji.mongodb.net/local_library?
                         ^
retryWrites=true&w=majority;
                     

SyntaxError: Unexpected token ':'
at wrapSafe (internal/modules/cjs/loader.js:1054:16)
at Module._compile (internal/modules/cjs/loader.js:1102:27)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10)
at Module.load (internal/modules/cjs/loader.js:986:32)
at Function.Module._load (internal/modules/cjs/loader.js:879:14)
at Module.require (internal/modules/cjs/loader.js:1026:19)
at require (internal/modules/cjs/helpers.js:72:18)
at Object.<anonymous> (C:\test-node\libraryapp\express-locallibrary-tutorial\bin\www:7:11)
at Module._compile (internal/modules/cjs/loader.js:1138:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10)
[nodemon] app crashed - waiting for file changes before starting...

以上消息似乎表明mongoDB URL出了点问题,但我对其进行了三倍检查,它看起来是正确的。我不确定引用bin \ www的错误指的是什么。在为数据库添加了模型之后,昨天我已经成功运行了服务器,但是在今天添加了路由和控制器之后,我收到了此消息。谢谢

0 个答案:

没有答案