我尝试删除package-lock.json和node_modules,然后使用npm install
重新安装,问题是相同的。我使用sudo运行npm start
或npm test
。
这就是我得到的:
$ npm run build
my-react-app@0.1.0 build /home/vagrant/projects/my-react-app
react-scripts build
sh: 1: react-scripts: not found npm ERR!
file sh npm ERR! code
ELIFECYCLE npm ERR! errno ENOENT npm ERR! syscall spawn npm ERR!
my-react-app@0.1.0 build: `react-scripts build` npm ERR! spawn ENOENT
npm ERR! npm ERR! Failed at the my-react-app@0.1.0 build script. npm
ERR! This is probably not a problem with npm. There is likely
additional logging output above.