【发布时间】:2022-01-09 21:05:48
【问题描述】:
我尝试执行两年前自己创建的旧 React 应用程序。当我尝试通过“npm install”运行应用程序时,出现以下错误:
npm ERR! must provide string spec
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\tws80\AppData\Local\npm-cache\_logs\2022-01-09T21_00_13_180Z-debug.log
我的 package.json 文件的依赖关系:
"dependencies": {
"@material-ui/core": "^4.9.7",
"@material-ui/icons": "^4.9.1",
"@mdi/js": "^5.0.45",
"@mdi/react": "^1.3.0",
"@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^9.4.1",
"@testing-library/user-event": "^7.2.1",
"editor.formatOnPaste": true,
"editor.formatOnSave": true,
"husky": "^4.2.3",
"i18next": "^19.3.3",
"lint-staged": "^10.0.8",
"prettier": "^1.19.1",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-html-email": "^3.0.0",
"react-i18next": "^11.3.3",
"react-intl": "^4.1.1",
"react-router-dom": "^5.1.2",
"react-scripts": "^5.0.0"
}
我当前的节点和 npm 版本:
node -v v16.13.1
npm -v 8.1.2
我想这个错误是由于旧的依赖关系造成的,但我没有找到任何有用的解决方法来解决这个问题。删除 node_modules 后,我仍然可以重新安装 node_modules。 感谢您的帮助。
【问题讨论】:
-
什么版本的 NPM?你能发布你的 package.json 吗?
-
@Joe,谢谢!上面可以看到我的npm版本和pyckage.json
-
您的 package.json 中还有其他部分吗?可能是
engines部分,或者可能是不再允许的旧 cmets 部分 ("//": {})? -
@Joe,在我的 package.json 中没有引擎部分,但在 package-lock.json 中有。另一方面,不存在旧的 cmets。