我有一个ReactJS项目,带有package.json文件:
{
"name": "front-end",
"version": "0.1.0",
"private": true,
"dependencies": {
"@testing-library/jest-dom": "^5.17.0",
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^13.5.0",
"bootstrap": "^5.3.2",
"cors": "^2.8.5",
"pg-promise": "^11.5.4",
"querystring": "^0.2.1",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-resizable": "^3.0.5",
"react-router-dom": "^6.16.0",
"react-scripts": "5.0.1",
"react-split-pane": "^0.1.92",
"web-vitals": "^2.1.4",
"zlib": "^1.0.5"
},
"devDependencies": {
"nodemon": "^2.0.22"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject",
"dev": "nodemon server.js"
},
"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"
]
}
}
每当我执行 npm install 时它都不起作用,因此我添加 --force 标志并得到:
npm error path C:\Users\MASTER\DatabaseViewerApp\front-end\node_modules\zlib
npm error command failed
npm error command C:\Windows\system32\cmd.exe /d /s /c node-waf clean || true; node-waf configure build
npm error System cannot find the path specified
npm error 'true' is not recognized as an internal or external command,
npm error operable program or batch file.
npm error A complete log of this run can be found in: C:\Users\MASTER\AppData\Local\npm-cache\_logs\2024-09-26T18_02_42_496Z-debug-0.log
当我执行 npn run dev 时,我可以看到某些库无法解析: 找不到模块:错误:无法解析“C:\Users\MASTER\DatabaseViewerApp ront-end\src”中的“react-router-dom”
即使我尝试使用 --force 安装此模块,它仍然会发生。
你必须将其分解才能找出不起作用的地方。 我可以提出很多建议,但问题的措辞非常广泛,而且可能有几处错误。
您是否尝试过
rm -rf node_modules package-lock.json
,然后再次npm install
?
如果这不起作用,我接下来的两个问题是:
这段代码是你写的还是从其他地方下载/生成的?
它曾经有效还是突然停止工作?