创建React应用程序后,NPM启动不起作用,每次都会遇到不同的错误
我尝试了npm init
,更新,缓存清除,node js
卸载和 没有任何帮助
已安装,但是在创建React App之后,npm
启动不起作用,每次都会遇到不同的错误:
D:\Downloads in Data drive\SourceCodes\Full Stack Web Development\NodeJs\Project A\client\node_modules\cross-spawn\lib\enoent.js:1
$→��m��mo�L�D��;�%g�?w��ŷ↓�▬��ovH0��a�5��*�ؒ��l͛�S�iy☺�r�O7����%L]��%��∟�hk
^
SyntaxError: Invalid or unexpected token
at Object.compileFunction (node:vm:352:18)
at wrapSafe (node:internal/modules/cjs/loader:1033:15)
at Module._compile (node:internal/modules/cjs/loader:1069:27)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.<anonymous> (D:\Downloads in Data drive\SourceCodes\Full Stack Web Development\NodeJs\Project A\client\node_modules\cross-spawn\index.js:5:16)
at Module._compile (node:internal/modules/cjs/loader:1105:14)
D:\Downloads in Data drive\SourceCodes\Full Stack Web Development\NodeJs\Project B\client copy\node_modules\path-to-regexp\index.js:1
$→��m��mo�L�D��;�%g�?w��ŷ↓�▬��ovH0��a�5��*�ؒ��l͛�S�iy☺�r�O7����%L]��%��∟�hk
^
SyntaxError: Invalid or unexpected token
at Object.compileFunction (node:vm:352:18)
at wrapSafe (node:internal/modules/cjs/loader:1033:15)
at Module._compile (node:internal/modules/cjs/loader:1069:27)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.<anonymous> (D:\Downloads in Data drive\SourceCodes\Full Stack Web Development\NodeJs\Project B\client copy\node_modules\express\lib\router\layer.js:16:18)
at Module._compile (node:internal/modules/cjs/loader:1105:14)
我的package.json,
{
"name": "client",
"version": "0.1.0",
"private": true,
"dependencies": {
"@testing-library/jest-dom": "^5.16.4",
"@testing-library/react": "^13.2.0",
"@testing-library/user-event": "^13.5.0",
"ajv-dist": "^8.11.0",
"react": "^18.1.0",
"react-dom": "^18.1.0",
"react-scripts": "5.0.1",
"web-vitals": "^2.1.4"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
I tried npm init
, update, cache clearing, node js
uninstalled and
installed, but nothing helped
After create react app, npm
start is not working, each time getting different errors:
D:\Downloads in Data drive\SourceCodes\Full Stack Web Development\NodeJs\Project A\client\node_modules\cross-spawn\lib\enoent.js:1
$→��m��mo�L�D��;�%g�?w��ŷ↓�▬��ovH0��a�5��*�ؒ��l͛�S�iy☺�r�O7����%L]��%��∟�hk
^
SyntaxError: Invalid or unexpected token
at Object.compileFunction (node:vm:352:18)
at wrapSafe (node:internal/modules/cjs/loader:1033:15)
at Module._compile (node:internal/modules/cjs/loader:1069:27)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.<anonymous> (D:\Downloads in Data drive\SourceCodes\Full Stack Web Development\NodeJs\Project A\client\node_modules\cross-spawn\index.js:5:16)
at Module._compile (node:internal/modules/cjs/loader:1105:14)
D:\Downloads in Data drive\SourceCodes\Full Stack Web Development\NodeJs\Project B\client copy\node_modules\path-to-regexp\index.js:1
$→��m��mo�L�D��;�%g�?w��ŷ↓�▬��ovH0��a�5��*�ؒ��l͛�S�iy☺�r�O7����%L]��%��∟�hk
^
SyntaxError: Invalid or unexpected token
at Object.compileFunction (node:vm:352:18)
at wrapSafe (node:internal/modules/cjs/loader:1033:15)
at Module._compile (node:internal/modules/cjs/loader:1069:27)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.<anonymous> (D:\Downloads in Data drive\SourceCodes\Full Stack Web Development\NodeJs\Project B\client copy\node_modules\express\lib\router\layer.js:16:18)
at Module._compile (node:internal/modules/cjs/loader:1105:14)
My Package.json
{
"name": "client",
"version": "0.1.0",
"private": true,
"dependencies": {
"@testing-library/jest-dom": "^5.16.4",
"@testing-library/react": "^13.2.0",
"@testing-library/user-event": "^13.5.0",
"ajv-dist": "^8.11.0",
"react": "^18.1.0",
"react-dom": "^18.1.0",
"react-scripts": "5.0.1",
"web-vitals": "^2.1.4"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
转到
命令提示符
,然后将目录定位在其中安装了节点JS并运行此命令:node -version
。如果显示您已安装的版本,请运行以下命令:
npm -version
。如果它不显示该版本,则出了问题。转到 node js官方网站并下载长期支持(LTS)node js js js eg 16.15.0 (根据答案的发布时间)。
然后安装并运行以前的命令,例如
node -version
&amp;npm - version
。错误应该消失。
Go to
Command Prompt
and locate the directory where you installed Node JS and run this command:node --version
.If it shows the version that you have installed, then run this command:
npm --version
. If it does not show the version then something is wrong.Go to Node JS Official Website and download the Long Term Support(LTS) version of Node JS e.g 16.15.0 (according to the posting time of the answer).
Then install it and run the previous commands e.g.
node --version
&npm --version
.The error should be gone.