我正在尝试为Grand Stack Starter构建启动程序api,但是每次尝试使用npm start
时都会失败:
>nodemon --exec babel-node src/index.js
[nodemon] 1.18.7
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: *.*
[nodemon] starting `babel-node src/index.js`
'babel-node' is not recognized as an internal or external command,
operable program or batch file.
[nodemon] app crashed - waiting for file changes before starting...
请注意,我确实事先运行过npm i
,并且可以运行其他项目(包括grand-stack-starter的UI项目)。我检查了node_modules文件夹,确实没有babel-node
软件包,但是当我直接安装它时,它失败了:
> babel-node@6.5.3 postinstall [project_path]\api\node_modules\babel-node
> node message.js; sleep 10; exit 1;
internal/modules/cjs/loader.js:583
throw err;
^
Error: Cannot find module '[project_path]\api\node_modules\babel-node\message.js;'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:581:15)
at Function.Module._load (internal/modules/cjs/loader.js:507:25)
at Function.Module.runMain (internal/modules/cjs/loader.js:742:12)
at startup (internal/bootstrap/node.js:282:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:743:3)
npm WARN grand-stack-starter-api@0.0.1 No repository field.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! babel-node@6.5.3 postinstall: `node message.js; sleep 10; exit 1;`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the babel-node@6.5.3 postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
我不知道这是否是我的PC特有的问题,但是任何帮助将不胜感激
答案 0 :(得分:0)
我重新安装了Node.js并删除了node_modules文件夹。之后,我运行了npm i,现在npm start可以正常运行了。看来问题出在我的环境上。
答案 1 :(得分:0)
尝试使用笔记本电脑时,我遇到了类似的问题。但是在docker容器中运行提供的dockerfile时未出现任何此类错误。这为我解决了所有此类依赖包问题。