![尝试运行 npm 时出现问题](https://linux22.com/image/1148417/%E5%B0%9D%E8%AF%95%E8%BF%90%E8%A1%8C%20npm%20%E6%97%B6%E5%87%BA%E7%8E%B0%E9%97%AE%E9%A2%98.png)
当我尝试sudo npm start
在我的项目文件夹中运行它在本地主机中时,它返回以下内容:
kallel@augustinho:~/PDIAP-master$ sudo npm start
[email protected] start /home/kallel/PDIAP-master
nodemon bin/www --exec babel-node --presets es2015
[nodemon] 1.11.0
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: *.*
[nodemon] starting `babel-node bin/www --presets es2015`
/usr/local/lib/node_modules/babel-cli/node_modules/babel-core/lib/transformation/file/options/option-manager.js:328
throw e;
^
Error: Couldn't find preset "es2015" relative to directory "/home/kallel/PDIAP-master"
at /usr/local/lib/node_modules/babel-cli/node_modules/babel core/lib/transformation/file/options/option-manager.js:293:19
at Array.map (native)
at OptionManager.resolvePresets (/usr/local/lib/node_modules/babel-cli/node_modules/babel-core/lib/transformation/file/options/option manager.js:275:20)
at OptionManager.mergePresets (/usr/local/lib/node_modules/babel-cli/node_modules/babel-core/lib/transformation/file/options/option-manager.js:264:10)
at OptionManager.mergeOptions (/usr/local/lib/node_modules/babel-cli/node_modules/babel-core/lib/transformation/file/options/option-manager.js:249:14)
at OptionManager.init (/usr/local/lib/node_modules/babel-cli/node_modules/babel-core/lib/transformation/file/options/option-manager.js:368:12)
at compile (/usr/local/lib/node_modules/babel-cli/node_modules/babel-register/lib/node.js:103:45)
at loader (/usr/local/lib/node_modules/babel-cli/node_modules/babel-register/lib/node.js:144:14)
at Object.require.extensions.(anonymous function) [as .js] (/usr/local/lib/node_modules/babel-cli/node_modules/babel-register/lib/node.js:154:7)
at Module.load (module.js:487:32)
[nodemon] app crashed - waiting for file changes before starting...`
答案1
对于遇到同样问题的人,只需使用 npm 在本地安装它所说的缺少的包即可sudo npm install [package-asked]
。
就我的情况而言,我必须运行sudo npm install es2015
并随后询问包裹,直到问题得到解决。
祝你晚安。 :)