我试图执行一个旧的反应应用,这是由我自己两年前创建的。当我试图通过"npm安装“运行该应用程序时,我得到了以下错误:
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。谢谢你的帮助。
发布于 2022-01-10 16:06:56
在bash终端上运行"rm -rf node_modules & rm -rf package-lock.json && npm“为我修复了它。
在本地机器上运行npm -v --> 8.3.0
发布于 2022-03-11 17:41:59
问题是,您将一些包选项放入package.json的“依赖”部分。我在自动修复程序浏览器列表选项上也有相同的错误。删除"editor.formatOnPaste": true
和"editor.formatOnSave": true
,npm安装将如预期的那样工作-我在本地检查了它。我的猜测是,在“依赖项”或"devDependencies“下,只需要包的版本。
发布于 2022-03-09 08:08:56
必须首先初始化npm包:
npm init
之后,你应该能够执行你的命令。
https://stackoverflow.com/questions/70645510
复制相似问题