[英]Error when trying to run npm start command
I am trying to create a react project i have run npx create-react-app hello-react --use-npm then cd hello-react but when I've npm start this error has been shown:我正在尝试创建一个反应项目,我已经运行 npx create-react-app hello-react --use-npm 然后 cd hello-react 但是当我运行 npm start 时,已显示此错误:
npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path C:\Users\develompent\Desktop\react\package.json
npm ERR! errno -4058
npm ERR! enoent ENOENT: no such file or directory, open 'C:\Users\develompent\Desktop\react\package.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\develompent\AppData\Roaming\npm-cache\_logs\2020-08-30T18_43_59_773Z-debug.log
C:\Users\develompent\Desktop\react>cd hello-react
C:\Users\develompent\Desktop\react\hello-react>npm start
> hello-react@0.1.0 start C:\Users\develompent\Desktop\react\hello-react
> react-scripts start
i 「wds」: Project is running at http://192.168.137.1/
i 「wds」: webpack output is served from
i 「wds」: Content not from webpack is served from C:\Users\develompent\Desktop\react\hello-react\public
i 「wds」: 404s will fallback to /
Starting the development server...
events.js:292
throw er; // Unhandled 'error' event
^
Error: spawn powershell ENOENT
at Process.ChildProcess._handle.onexit (internal/child_process.js:267:19)
at onErrorNT (internal/child_process.js:469:16)
at processTicksAndRejections (internal/process/task_queues.js:84:21)
Emitted 'error' event on ChildProcess instance at:
at Process.ChildProcess._handle.onexit (internal/child_process.js:273:12)
at onErrorNT (internal/child_process.js:469:16)
at processTicksAndRejections (internal/process/task_queues.js:84:21) {
errno: 'ENOENT',
code: 'ENOENT',
syscall: 'spawn powershell',
path: 'powershell',
spawnargs: [
'-NoProfile',
'-NonInteractive',
'–ExecutionPolicy',
'Bypass',
'-EncodedCommand',
'UwB0AGEAcgB0ACAAIgBgACIAaAB0AHQAcAA6AC8ALwBsAG8AYwBhAGwAaABvAHMAdAA6ADMAMAAwADAAYAAiACIA'
]
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! hello-react@0.1.0 start: `react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the hello-react@0.1.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! C:\Users\develompent\AppData\Roaming\npm-cache\_logs\2020-08-30T18_44_47_550Z-debug.log
i have tried to to delete the node_modules then I've installed it another time but the same issue still happening and I also tried to run the cmd as an administrator but it did not open without showing any errors我试图删除 node_modules 然后我又安装了一次,但同样的问题仍然发生,我也尝试以管理员身份运行 cmd 但它没有打开而没有显示任何错误
downgrade react scripts for project with these commands使用这些命令降级项目的反应脚本
npm install react-scripts@2.1.8
npm start
Create a new folder and try with this:创建一个新文件夹并尝试这样做:
npx create-react-app my-app
cd my-app
npm start
You'll need to have Node >= 8.10 and npm >= 5.6 on your machine你需要在你的机器上安装 Node >= 8.10 和 npm >= 5.6
https://reactjs.org/docs/create-a-new-react-app.html
https://reactjs.org/docs/create-a-new-react-app.html
You can try to reinstall node in the path C:\\windows\\System32
可以尝试在
C:\\windows\\System32
路径下重新安装node
or you can或者你可以
Follow these steps:按着这些次序:
npm cache clean --force
node_modules
foldernode_modules
文件夹package-lock.json
filepackage-lock.json
文件npm install
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.