我尝试了npm init
,更新,缓存清理,node js
卸载和已安装,但没有任何帮助
创建react app后,npm
启动不工作,每次得到不同的错误:
D:Downloads in Data driveSourceCodesFull Stack Web DevelopmentNodeJsProject Aclientnode_modulescross-spawnlibenoent.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 driveSourceCodesFull Stack Web DevelopmentNodeJsProject Aclientnode_modulescross-spawnindex.js:5:16)
at Module._compile (node:internal/modules/cjs/loader:1105:14)
D:Downloads in Data driveSourceCodesFull Stack Web DevelopmentNodeJsProject Bclient copynode_modulespath-to-regexpindex.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 driveSourceCodesFull Stack Web DevelopmentNodeJsProject Bclient copynode_modulesexpresslibrouterlayer.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"
]
}
}
进入Command Prompt
,找到Node JS的安装目录,执行以下命令:node --version
。如果显示的是已安装的版本,则运行以下命令:npm --version
。如果没有显示版本,则说明有问题。
到Node JS官方网站下载Node JS的长期支持(LTS)版本,例如16.15.0(根据答案的发布时间)。然后安装它并运行前面的命令,例如node --version
&npm --version
.
错误应该消失。