Hay*_*yan 15 npm reactjs npm-install yarnpkg yarn-workspaces
我正在尝试在我的项目中安装依赖项,但是当我运行时yarn install出现以下错误
[2/5] Resolving packages...\ninfo There appears to be trouble with the npm registry (returned undefined). Retrying...\ninfo There appears to be trouble with the npm registry (returned undefined). Retrying...\ninfo There appears to be trouble with the npm registry (returned undefined). Retrying...\ninfo There appears to be trouble with the npm registry (returned undefined). Retrying...\n\xe2\xa0\x81 axios@0.21.1/usr/local/Cellar/yarn/1.22.10/libexec/lib/cli.js:66965\n throw new (_errors || _load_errors()).ResponseError(_this3.reporter.lang('requestFailed', description), res.statusCode);\n ^\n\nResponseError: Request failed "502 Bad Gateway"\n at ResponseError.ExtendableBuiltin (/usr/local/Cellar/yarn/1.22.10/libexec/lib/cli.js:696:66)\n at new ResponseError (/usr/local/Cellar/yarn/1.22.10/libexec/lib/cli.js:802:124)\n at Request.params.callback [as _callback] (/usr/local/Cellar/yarn/1.22.10/libexec/lib/cli.js:66965:19)\n at Request.self.callback (/usr/local/Cellar/yarn/1.22.10/libexec/lib/cli.js:140749:22)\n at Request.emit (events.js:315:20)\n at Request.<anonymous> (/usr/local/Cellar/yarn/1.22.10/libexec/lib/cli.js:141721:10)\n at Request.emit (events.js:315:20)\n at IncomingMessage.<anonymous> (/usr/local/Cellar/yarn/1.22.10/libexec/lib/cli.js:141643:12)\n at Object.onceWrapper (events.js:421:28)\n at IncomingMessage.emit (events.js:327:22) {\n responseCode: 502\n}\nRun Code Online (Sandbox Code Playgroud)\n我试过
\nyarn.lock文件并yarn install再次运行yarn install --network-timeout 100000仍然遇到同样的错误
\n小智 3
这对我有用:
删除任何“*.lock”和 rm node_modules。或者 rm -rf node_modules/
清理并刷新所有连接,例如 DNS、缓存等。
终端命令:
set http_proxy=
set https_proxy=
yarn config delete proxy
npm config rm https-proxy
npm config rm proxy
Run Code Online (Sandbox Code Playgroud)
npm config set registry "http://registry.npmjs.org"或者npm config set registry "https://registry.npmjs.org"
重新启动您的终端并尝试。
使用 :yarn add mypckge --network-timeout 100000 or yarn --network-timeout 100000
但首先尝试一下yarn
重新启动您的终端并再次尝试yarn和/或使用--network-timeout.