如何解决在Reactjs App执行'npm start'后如何删除启动脚本错误
我开始在Reactjs中创建一个项目,并且正在观看Youtube上的教程。使用“ npx create-react-app”创建项目后,当我尝试执行“ npm start”时,显示了很多错误:
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! covid-19-tracker@0.1.0 start: `react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the covid-19-tracker@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\VIVIDH\AppData\Roaming\npm-cache\_logs\2020-09-10T05_26_49_684Z-debug.log
npm -v = 6.14.8 节点-v 14.4.0 我已经尝试了大多数方法,但仍然无法正常工作。这是我的package.json文件:
{
"name": "covid-19-tracker","version": "0.1.0","private": true,"dependencies": {
"@testing-library/jest-dom": "^4.2.4","@testing-library/react": "^9.5.0","@testing-library/user-event": "^7.2.1","react": "^16.13.1","react-dom": "^16.13.1","react-scripts": "3.4.3"
},"scripts": {
"start": "react-scripts start","build": "react-scripts build","test": "react-scripts test","eject": "react-scripts eject"
},"eslintConfig": {
"extends": "react-app"
},"browserslist": {
"production": [
">0.2%","not dead","not op_mini all"
],"development": [
"last 1 chrome version","last 1 firefox version","last 1 safari version"
]
},"description": "This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).","main": "index.js","devDependencies": {},"repository": {
"type": "git","url": "git+https://github.com/Vividh25/covid-19-tracker.git"
},"author": "Vividh Bhardwaj","license": "ISC","bugs": {
"url": "https://github.com/Vividh25/covid-19-tracker/issues"
},"homepage": "https://github.com/Vividh25/covid-19-tracker#readme"
}
Debug.log:
0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli 'C:\\Program Files\\nodejs\\node.exe',1 verbose cli 'C:\\Users\\VIVIDH\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js',1 verbose cli 'start'
1 verbose cli ]
2 info using npm@6.14.8
3 info using node@v14.4.0
4 verbose run-script [ 'prestart','start','poststart' ]
5 info lifecycle covid-19-tracker@0.1.0~prestart: covid-19-tracker@0.1.0
6 info lifecycle covid-19-tracker@0.1.0~start: covid-19-tracker@0.1.0
7 verbose lifecycle covid-19-tracker@0.1.0~start: unsafe-perm in lifecycle true
8 verbose lifecycle covid-19-tracker@0.1.0~start: PATH: C:\Users\VIVIDH\AppData\Roaming\npm\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;C:\Users\VIVIDH\desktop\Projects\covid-19-tracker\node_modules\.bin;C:\python38\Scripts\;C:\python38\;C:\Windows\System32;D:\src\Flutter\bin;C:\src\Git\cmd;C:\src\Git\cmd\git.exe;C:\Program Files\nodejs\;C:\ProgramData\chocolatey\bin;C:\Program Files (x86)\NVIDIA Corporation\physx\Common;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\Program Files\Git\cmd;C:\Windows\System32\ variable;"C:\Users\VIVIDH\AppData\Local\Microsoft\WindowsApps;C:\src\Git\cmd\git.exe;C:\src\Git\cmd";D:\Microsoft VS Code\bin;C:\Users\VIVIDH\AppData\Roaming\npm
9 verbose lifecycle covid-19-tracker@0.1.0~start: CWD: C:\Users\VIVIDH\desktop\Projects\covid-19-tracker
10 silly lifecycle covid-19-tracker@0.1.0~start: Args: [ '/d /s /c','react-scripts start' ]
11 silly lifecycle covid-19-tracker@0.1.0~start: Returned: code: 1 signal: null
12 info lifecycle covid-19-tracker@0.1.0~start: Failed to exec start script
13 verbose stack Error: covid-19-tracker@0.1.0 start: `react-scripts start`
13 verbose stack Exit status 1
13 verbose stack at EventEmitter.<anonymous> (C:\Users\VIVIDH\AppData\Roaming\npm\node_modules\npm\node_modules\npm-lifecycle\index.js:332:16)
13 verbose stack at EventEmitter.emit (events.js:315:20)
13 verbose stack at ChildProcess.<anonymous> (C:\Users\VIVIDH\AppData\Roaming\npm\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
13 verbose stack at ChildProcess.emit (events.js:315:20)
13 verbose stack at maybeClose (internal/child_process.js:1051:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:287:5)
14 verbose pkgid covid-19-tracker@0.1.0
15 verbose cwd C:\Users\VIVIDH\desktop\Projects\covid-19-tracker
16 verbose Windows_NT 10.0.18362
17 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\VIVIDH\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "start"
18 verbose node v14.4.0
19 verbose npm v6.14.8
20 error code ELIFECYCLE
21 error errno 1
22 error covid-19-tracker@0.1.0 start: `react-scripts start`
22 error Exit status 1
23 error Failed at the covid-19-tracker@0.1.0 start script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1,true ]
请帮助我。
解决方法
这是system variable path
的问题。
执行此操作。
转到>控制面板\系统和安全性\系统\高级系统设置\环境变量和set system variables path C:\Windows\System32\ variable
,然后重新启动。
如果您遇到相同的问题并尝试了所有方法,但仍然无法正常工作,请尝试通过yarn运行项目。您可以从下载nodejs时预装的Chocolatey中安装yarn。这是您在cmd上输入的内容:
choco install yarn
安装后:
yarn init
要启动项目:
yarn create react-app <your project name>
cd <your project name>
yarn start
这对我有用,并希望对您有用:)
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。