npm install 遇到问题
Posted
技术标签:
【中文标题】npm install 遇到问题【英文标题】:run into problems with npm install 【发布时间】:2021-10-16 22:48:27 【问题描述】:我只是从 github 克隆我的项目,但是当我运行 npm install 时,发生了错误。
这个项目在我的电脑上完美运行。但是,它甚至无法在我的 linux 笔记本电脑上初始化。有什么解决办法吗?
这是错误信息,
npm ERR! code E404
npm ERR! 404 Not Found - GET https://registry.npmjs.org/@testing-yarnlibrary%2freact - Not found
npm ERR! 404
npm ERR! 404 '@testing-yarnlibrary/react@^11.1.0' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
npm ERR! 404
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/anthonyzhang/.npm/_logs/2021-08-13T17_45_59_614Z-debug.log
package.json,
"name": "qrcode-ordering",
"version": "0.1.0",
"private": true,
"dependencies":
"@testing-library/jest-dom": "^5.11.4",
"@testing-yarnlibrary/react": "^11.1.0",
"@testing-library/user-event": "^12.1.10",
"bootstrap": "^5.1.0",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-icons": "^4.2.0",
"react-router-dom": "^5.2.0",
"react-scripts": "4.0.3",
"web-vitals": "^1.0.1"
,
"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"
]
,
"devDependencies":
"@fortawesome/fontawesome-free": "^5.15.4",
"css-loader": "^6.2.0",
"style-loader": "^3.2.1"
【问题讨论】:
读取它正在寻找的包的名称 - 这似乎不对,检查包中的内容并锁定文件。 @jonrsharpe 我也注意到了。这是我在package.json
, ``` "@testing-yarnlibrary/react": "^11.1.0" ``` 中的依赖,这就是 yarn.lock
, "@testing-library/react@^11.1.0": version "11.2.7" resolved "https://registry.npmjs.org/@testing-library/react/-/react-11.2.7.tgz" integrity sha512-tzRNp7pzd5QmbtXNG/mhdcl7Awfu/Iz1RaVHY75zTdOkmHCuzMhRL83gWHSgOAcjS3CCbyfwUHMZgRJb4kAfpA== dependencies: "@babel/runtime" "^7.12.5" "@testing-library/dom" "^7.28.1"
这显然不是现有包的名称,所以你为什么不修复它,看看是否能解决问题?
谢谢!我相信它现在正在工作。
【参考方案1】:
您在 package.json 中将 @testing-library/react
拼错为 @testing-yarnlibrary/react
https://yarnpkg.com/package/@testing-library/react
【讨论】:
我的存储库中没有package-lock.json
。我删除了整个文件夹,然后再次克隆存储库。这次我运行yarn install
,这就是我得到的,yarn install v1.22.5 [1/4] Resolving packages... error An unexpected error occurred: "https://registry.yarnpkg.com/@testing-yarnlibrary%2freact: Not found". info If you think this is a bug, please open a bug report with the information provided in "/home/anthonyzhang/Documents/qrcode-ordering/yarn-error.log". info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
你能发布你的 package.json 吗?您可能打错了@testing-yarnlibrary/react
或选择了不存在的版本
我用正确的解决方案更新了我的答案
当然。我会将其发布在我上面编辑过的问题中。
看看我更新的答案。 "@testing-yarnlibrary/react": "^11.1.0" 不是真正的依赖,应该是 "@testing-library/react": "^11.1.0"以上是关于npm install 遇到问题的主要内容,如果未能解决你的问题,请参考以下文章
我在使用 npm install express 时遇到问题
当我运行“npm install”时,我遇到了我不明白的 npm 问题
当我在 docker 上执行 npm install 时出现问题