npm 命令 create-react-app 失败
npm command create-react-app failled
我正在尝试在我的计算机上测试 reactjs (mbp pro 2017) 运行 OsX sierra 10.12.6。
我已遵循 Facebook 教程:
- 确保您安装了 Node.js 的最新版本。 (完成)
- 按照安装说明创建一个新项目。 https://facebook.github.io/react/docs/installation.html#creating-a-new-application
但是我在第二步遇到了问题!
- 我没有使用代理。
- 我的网络没问题
- 存储库设置为 registry.npmjs.org
- 我可以阅读 url : https://registry.npmjs.org/create-react-app
- 但是即使在外部 DNS 上也找不到这个域 wsg.intra.corp.grp
我被卡住了,任何帮助都会很好!
$ npm install -g create-react-app
npm ERR! code ENOTFOUND
npm ERR! errno ENOTFOUND
npm ERR! network request to https://registry.npmjs.org/create-react-app failed, reason: getaddrinfo ENOTFOUND wsg.intra.corp.grp wsg.intra.corp.grp:8080
npm ERR! network This is a problem related to network connectivity.
npm ERR! network In most cases you are behind a proxy or have bad network settings.
npm ERR! network
npm ERR! network If you are behind a proxy, please make sure that the
npm ERR! network 'proxy' config is set properly. See: 'npm help config'
npm ERR! A complete log of this run can be found in:
npm ERR! ~/.npm/_logs/2017-09-01T08_15_13_521Z-debug.log
和日志文件:
0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node',
1 verbose cli '/usr/local/bin/npm',
1 verbose cli 'install',
1 verbose cli '-g',
1 verbose cli 'create-react-app' ]
2 info using npm@5.3.0
3 info using node@v8.4.0
4 verbose npm-session 4811d091ad74f9ef
5 silly install loadCurrentTree
6 silly install readGlobalPackageData
7 silly fetchPackageMetaData error for create-react-app@latest request to https://registry.npmjs.org/create-react-app failed, reason: getaddrinfo ENOTFOUND wsg.intra.corp.grp wsg.intra.corp.grp:8080
8 verbose type system
9 verbose stack FetchError: request to https://registry.npmjs.org/create-react-app failed, reason: getaddrinfo ENOTFOUND wsg.intra.corp.grp wsg.intra.corp.grp:8080
9 verbose stack at ClientRequest.req.on.err (/usr/local/lib/node_modules/npm/node_modules/pacote/node_modules/make-fetch-happen/node_modules/node-fetch-npm/src/index.js:68:14)
9 verbose stack at emitOne (events.js:115:13)
9 verbose stack at ClientRequest.emit (events.js:210:7)
9 verbose stack at onerror (/usr/local/lib/node_modules/npm/node_modules/pacote/node_modules/make-fetch-happen/node_modules/https-proxy-agent/node_modules/agent-base/index.js:106:9)
9 verbose stack at callbackError (/usr/local/lib/node_modules/npm/node_modules/pacote/node_modules/make-fetch-happen/node_modules/https-proxy-agent/node_modules/agent-base/index.js:126:5)
9 verbose stack at <anonymous>
9 verbose stack at process._tickCallback (internal/process/next_tick.js:188:7)
10 verbose cwd /Users/franckfournier/PycharmProjects/projectX/react
11 verbose Darwin 16.7.0
12 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "-g" "create-react-app"
13 verbose node v8.4.0
14 verbose npm v5.3.0
15 error code ENOTFOUND
16 error errno ENOTFOUND
17 error network request to https://registry.npmjs.org/create-react-app failed, reason: getaddrinfo ENOTFOUND wsg.intra.corp.grp wsg.intra.corp.grp:8080
18 error network This is a problem related to network connectivity.
18 error network In most cases you are behind a proxy or have bad network settings.
18 error network
18 error network If you are behind a proxy, please make sure that the
18 error network 'proxy' config is set properly. See: 'npm help config'
19 verbose exit [ 1, true ]
您似乎在使用公司代理,正如日志中提到的 wsg.intra.corp.grp:8080
。
您需要像 this guide 中所示配置代理。
希望对您有所帮助!
在 Github 上关注 this post,并在我的 /etc/hosts 中添加“104.18.95.96 registry.npmjs.org”解决了我的问题。
如果您仍然遇到问题,请按照以下步骤操作:
- 转到“设置”>“网络和 Internet”>“代理”并找出地址和端口
- 根据您的机器转到命令提示符或终端(提示:按 Win + R 并键入 cmd)。在命令提示符中键入以下命令
npm 配置设置代理 http://usernamepassword@proxy-server-url:port
npm 配置设置 https 代理 http://usernamepassword@proxy-server-url:port
10 次中有 9 次确实不需要用户名和密码,最后 2 次就足够了。 Proxy-server-url是你的地址,你的端口是端口号。一旦设置关闭命令提示符并重新打开它。瞧!您现在可以安装所有软件包
来源: https://medium.com/@ogbemudiatimothy/using-npm-install-behind-a-corporate-proxy-server-db150c128899
我解决了这个问题,
转到设置 > 网络和 Internet > 代理,然后在 Windows 上的自动代理设置下关闭自动检测设置。然后安装正常。
运行 命令提示符下的命令。确保安装了 node 和 npm。
npm config rm proxy
npm config rm https-proxy
在浏览器中打开此 link:https://registry.npmjs.org/
运行 下面的命令设置注册表。
npm config set registry https://registry.npmjs.org/
希望对您有所帮助:)
我正在尝试在我的计算机上测试 reactjs (mbp pro 2017) 运行 OsX sierra 10.12.6。 我已遵循 Facebook 教程:
- 确保您安装了 Node.js 的最新版本。 (完成)
- 按照安装说明创建一个新项目。 https://facebook.github.io/react/docs/installation.html#creating-a-new-application
但是我在第二步遇到了问题!
- 我没有使用代理。
- 我的网络没问题
- 存储库设置为 registry.npmjs.org
- 我可以阅读 url : https://registry.npmjs.org/create-react-app
- 但是即使在外部 DNS 上也找不到这个域 wsg.intra.corp.grp
我被卡住了,任何帮助都会很好!
$ npm install -g create-react-app
npm ERR! code ENOTFOUND
npm ERR! errno ENOTFOUND
npm ERR! network request to https://registry.npmjs.org/create-react-app failed, reason: getaddrinfo ENOTFOUND wsg.intra.corp.grp wsg.intra.corp.grp:8080
npm ERR! network This is a problem related to network connectivity.
npm ERR! network In most cases you are behind a proxy or have bad network settings.
npm ERR! network
npm ERR! network If you are behind a proxy, please make sure that the
npm ERR! network 'proxy' config is set properly. See: 'npm help config'
npm ERR! A complete log of this run can be found in:
npm ERR! ~/.npm/_logs/2017-09-01T08_15_13_521Z-debug.log
和日志文件:
0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node',
1 verbose cli '/usr/local/bin/npm',
1 verbose cli 'install',
1 verbose cli '-g',
1 verbose cli 'create-react-app' ]
2 info using npm@5.3.0
3 info using node@v8.4.0
4 verbose npm-session 4811d091ad74f9ef
5 silly install loadCurrentTree
6 silly install readGlobalPackageData
7 silly fetchPackageMetaData error for create-react-app@latest request to https://registry.npmjs.org/create-react-app failed, reason: getaddrinfo ENOTFOUND wsg.intra.corp.grp wsg.intra.corp.grp:8080
8 verbose type system
9 verbose stack FetchError: request to https://registry.npmjs.org/create-react-app failed, reason: getaddrinfo ENOTFOUND wsg.intra.corp.grp wsg.intra.corp.grp:8080
9 verbose stack at ClientRequest.req.on.err (/usr/local/lib/node_modules/npm/node_modules/pacote/node_modules/make-fetch-happen/node_modules/node-fetch-npm/src/index.js:68:14)
9 verbose stack at emitOne (events.js:115:13)
9 verbose stack at ClientRequest.emit (events.js:210:7)
9 verbose stack at onerror (/usr/local/lib/node_modules/npm/node_modules/pacote/node_modules/make-fetch-happen/node_modules/https-proxy-agent/node_modules/agent-base/index.js:106:9)
9 verbose stack at callbackError (/usr/local/lib/node_modules/npm/node_modules/pacote/node_modules/make-fetch-happen/node_modules/https-proxy-agent/node_modules/agent-base/index.js:126:5)
9 verbose stack at <anonymous>
9 verbose stack at process._tickCallback (internal/process/next_tick.js:188:7)
10 verbose cwd /Users/franckfournier/PycharmProjects/projectX/react
11 verbose Darwin 16.7.0
12 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "-g" "create-react-app"
13 verbose node v8.4.0
14 verbose npm v5.3.0
15 error code ENOTFOUND
16 error errno ENOTFOUND
17 error network request to https://registry.npmjs.org/create-react-app failed, reason: getaddrinfo ENOTFOUND wsg.intra.corp.grp wsg.intra.corp.grp:8080
18 error network This is a problem related to network connectivity.
18 error network In most cases you are behind a proxy or have bad network settings.
18 error network
18 error network If you are behind a proxy, please make sure that the
18 error network 'proxy' config is set properly. See: 'npm help config'
19 verbose exit [ 1, true ]
您似乎在使用公司代理,正如日志中提到的 wsg.intra.corp.grp:8080
。
您需要像 this guide 中所示配置代理。
希望对您有所帮助!
在 Github 上关注 this post,并在我的 /etc/hosts 中添加“104.18.95.96 registry.npmjs.org”解决了我的问题。
如果您仍然遇到问题,请按照以下步骤操作:
- 转到“设置”>“网络和 Internet”>“代理”并找出地址和端口
- 根据您的机器转到命令提示符或终端(提示:按 Win + R 并键入 cmd)。在命令提示符中键入以下命令
npm 配置设置代理 http://usernamepassword@proxy-server-url:port
npm 配置设置 https 代理 http://usernamepassword@proxy-server-url:port
10 次中有 9 次确实不需要用户名和密码,最后 2 次就足够了。 Proxy-server-url是你的地址,你的端口是端口号。一旦设置关闭命令提示符并重新打开它。瞧!您现在可以安装所有软件包
来源: https://medium.com/@ogbemudiatimothy/using-npm-install-behind-a-corporate-proxy-server-db150c128899
我解决了这个问题, 转到设置 > 网络和 Internet > 代理,然后在 Windows 上的自动代理设置下关闭自动检测设置。然后安装正常。
运行 命令提示符下的命令。确保安装了 node 和 npm。
npm config rm proxy
npm config rm https-proxy
在浏览器中打开此 link:https://registry.npmjs.org/
运行 下面的命令设置注册表。
npm config set registry https://registry.npmjs.org/
希望对您有所帮助:)