我正在尝试解决package.json中的路径错误。如何正确设置路径?是错字还是项目文件夹中缺少server.js?
npm install->没有错误
npm start(在项目文件夹中)->显示错误(因为我不是解决问题的专家)我查看了该错误并搜索了所有可能的解决方案。我尝试了npm install -g看看它是否可以解决问题(对某些人来说确实做到了,但没有取得进展)。
错误是:
reactApp git:(master) ✗ npm start
> react_proj@1.0.0 start /home/pck/reactApp
> node './http_server.js'
internal/modules/cjs/loader.js:651
throw err;
^
Error: Cannot find module '/home/pck/reactApp/http_server.js'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:649:15)
at Function.Module._load (internal/modules/cjs/loader.js:575:25)
at Function.Module.runMain (internal/modules/cjs/loader.js:862:12)
at internal/main/run_main_module.js:21:11
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! react_proj@1.0.0 start: `node './http_server.js'`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the react_proj@1.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/pck/.npm/_logs/2019-04-01T15_47_30_710Z-debug.log
在package.json中:
"scripts": {
"start": "node '~/http_server.js'",
"watch": "karma start karma.conf.js --singleRun=false",
"test": "echo \"Error: no test specified\" && exit 1"
我还安装了一个软件包。它安装了一个http_server.js。我试图将http_server.js与package.json链接,但是没有成功。
答案 0 :(得分:0)
http_server在您的主目录中吗?
答案 1 :(得分:0)
好的,我已经尝试并解决了自己的问题。我只需要修复package.json中的脚本/路径即可。
开始的脚本是:
sudo pip install --upgrade cython==0.28.6
sudo dpkg --add-architecture i386
sudo apt update
sudo apt install build-essential ccache git libncurses5:i386 libstdc++6:i386 libgtk2.0-0:i386 libpangox-1.0-0:i386 libpangoxft-1.0-0:i386 libidn11:i386 python2.7 python2.7-dev openjdk-8-jdk unzip zlib1g-dev zlib1g:i386
进入
"scripts": {
"start": "node '~/http_server.js'",