我正在关注 MERN 上的这个 youtube 教程。
视频链接:
https://www.youtube.com/watch?v=xKs2IZZya7c&ab_channel=CodingWithDawid
申请github链接:
https://github.com/dejwid/mern-blog
在视频的第 45:00 分钟,他提到安装 nodemon 没有 太详细了。我安装了这个但是 nodemon 不工作。当我在命令提示符下键入时:
nodemon index.js
出现错误信息:
nodemon:术语“nodemon”不被识别为一个名称 cmdlet、函数、脚本文件或可运行的程序。检查拼写 名称的名称,或者,如果包含路径,请验证该路径是 更正并重试。 在线:1 字符:1 + nodemon index.js + ~~~~~~~ + CategoryInfo:ObjectNotFound:(nodemon:String)[],CommandNotFoundEx 概念 + FullyQualifiedErrorId:CommandNotFoundException
nodemon 是全局安装的,你可以在我的 package.json 中看到
package.json:
{
"dependencies": {
"express": "^4.18.2",
"g": "^2.0.1",
"react-router-dom": "^6.10.0"
},
"devDependencies": {
"nodemon": "^2.0.22"
}
}
解决方案是运行为:
npx nodemon index.js
或者全局安装 nodemon,以便它可以作为 cli 命令使用:
npm install -g nodemon
参考:https://www.npmjs.com/package/nodemon&https://nodemon.io/
您可以在
scripts
对象中添加命令作为键名 start
在 package.json 中,如下所示,您可以使用 npm start
. 运行您的应用程序
"scripts": {
"start": "nodemon index.js",
}