怎么解决egg.js在运行npm run dev时报错?
问题描述
启动egg脚手架之后,我只安装了egg-mongoose和egg-emqtt,进行简单的设置以及按照npm给出的示例新增了部分代码(设置、路由、控制器、中间件)。然后启动项目npm run dev
出现报错日志如下:
0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli '/usr/local/Cellar/node/12.6.0/bin/node',
1 verbose cli '/usr/local/bin/npm',
1 verbose cli 'run',
1 verbose cli 'dev'
1 verbose cli ]
2 info using npm@6.7.0
3 info using node@v12.6.0
4 verbose run-script [ 'predev', 'dev', 'postdev' ]
5 info lifecycle bulb-server@1.0.0~predev: bulb-server@1.0.0
6 info lifecycle bulb-server@1.0.0~dev: bulb-server@1.0.0
7 verbose lifecycle bulb-server@1.0.0~dev: unsafe-perm in lifecycle true
8 verbose lifecycle bulb-server@1.0.0~dev: PATH: /usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/Users/eichner/Projects/bulb-js/bulb-server/node_modules/.bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Applications/Android Studio.app/Contents/gradle/gradle-4.10.1/bin:/usr/local/Cellar/rabbitmq/3.8.3/sbin:/Applications/Android Studio.app/Contents/gradle/gradle-4.10.1/bin:/usr/local/Cellar/rabbitmq/3.8.3/sbin
9 verbose lifecycle bulb-server@1.0.0~dev: CWD: /Users/eichner/Projects/bulb-js/bulb-server
10 silly lifecycle bulb-server@1.0.0~dev: Args: [ '-c', 'egg-bin dev' ]
11 silly lifecycle bulb-server@1.0.0~dev: Returned: code: 1 signal: null
12 info lifecycle bulb-server@1.0.0~dev: Failed to exec dev script
13 verbose stack Error: bulb-server@1.0.0 dev: `egg-bin dev`
13 verbose stack Exit status 1
13 verbose stack at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:301:16)
13 verbose stack at EventEmitter.emit (events.js:203:13)
13 verbose stack at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack at ChildProcess.emit (events.js:203:13)
13 verbose stack at maybeClose (internal/child_process.js:1021:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:283:5)
14 verbose pkgid bulb-server@1.0.0
15 verbose cwd /Users/eichner/Projects/bulb-js/bulb-server
16 verbose Darwin 19.3.0
17 verbose argv "/usr/local/Cellar/node/12.6.0/bin/node" "/usr/local/bin/npm" "run" "dev"
18 verbose node v12.6.0
19 verbose npm v6.7.0
20 error code ELIFECYCLE
21 error errno 1
22 error bulb-server@1.0.0 dev: `egg-bin dev`
22 error Exit status 1
23 error Failed at the bulb-server@1.0.0 dev script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]
问题出现的环境背景及自己尝试过哪些方法
1.yarn试过了也是报错。
2.搭建egg脚手架直接运行npm run dev
是可以的。
3.清除npm缓存,删除node_modules文件夹,重新执行npm install
以及npm run dev
还是报错。
你期待的结果是什么?实际看到的错误信息又是什么?
我不知道是什么原因导致的这个报错,又何如解决使其能够正常运行?谢谢!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这种问题一般是node_module中的依赖包出现的问题,建议切换一下npm的镜像源为阿里的镜像源,因为墙的缘故会使下载依赖包出现问题。