npm create-react-app出错的解决方法

Microsoft Windows [版本 10.0.17763.652]
(c) 2018 Microsoft Corporation。保留所有权利。

C:\Users\sam>npm install -g react
+ [email protected]
added 5 packages and updated 1 package in 46.018s

C:\Users\sam>npm install -g create-react-app
C:\Users\sam\AppData\Roaming\npm\create-react-app -> C:\Users\sam\AppData\Roaming\npm\node_modules\create-react-app\index.js
+ [email protected]
updated 1 package in 29.647s

C:\Users\sam>create-react-app my-app

Creating a new React app in C:\Users\sam\my-app.

You are using Node v8.9.4 so the project will be bootstrapped with an old unsupported version of tools.

Please update to Node 8.10 or higher for a better, fully supported experience.

Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts...

yarn add v1.17.3
info No lockfile found.
[1/4] Resolving packages...
error An unexpected error occurred: "%27https://registry.npm.taobao.org%27/react: Invalid URI \"%27https://registry.npm.taobao.org%27/react\"".
info If you think this is a bug, please open a bug report with the information provided in "C:\\Users\\sam\\my-app\\yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.

Aborting installation.
  yarnpkg add --exact react react-dom [email protected] --cwd C:\Users\sam\my-app has failed.

Deleting generated file... package.json
Done.

C:\Users\sam>npm config set registry https://registry.npmjs.org/

C:\Users\sam>create-react-app my-app

Creating a new React app in C:\Users\sam\my-app.

You are using Node v8.9.4 so the project will be bootstrapped with an old unsupported version of tools.

Please update to Node 8.10 or higher for a better, fully supported experience.

Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts...

yarn add v1.17.3
info No lockfile found.
[1/4] Resolving packages...
info There appears to be trouble with your network connection. Retrying...
warning react-scripts > [email protected]: Deprecated. Please use https://github.com/webpack-contrib/mini-css-extract-plugin
warning react-scripts > [email protected]: Way too old
warning react-scripts > autoprefixer > [email protected]: Browserslist 2 could fail on reading Browserslist >3.0 config used in other tools.
warning react-scripts > css-loader > cssnano > autoprefixer > [email protected]: Browserslist 2 could fail on reading Browserslist >3.0 config used in other tools.
info There appears to be trouble with your network connection. Retrying...
warning react-scripts > babel-preset-react-app > babel-preset-env > [email protected]: Browserslist 2 could fail on reading Browserslist >3.0 config used in other tools.
warning react-scripts > css-loader > cssnano > postcss-merge-rules > [email protected]: Browserslist 2 could fail on reading Browserslist >3.0 config used in other tools.
info There appears to be trouble with your network connection. Retrying...
warning react-scripts > fsevents > node-pre-gyp > [email protected]: This module moved to @hapi/hawk. Please make sure to switch over as this distribution is no longer supported and may contain bugs and critical security issues.
warning react-scripts > fsevents > node-pre-gyp > request > [email protected]: This module moved to @hapi/hawk. Please make sure to switch over as this distribution is no longer supported and may contain bugs and critical security issues.
warning react-scripts > css-loader > cssnano > postcss-merge-rules > caniuse-api > [email protected]: Browserslist 2 could fail on reading Browserslist >3.0 config used in other tools.
info There appears to be trouble with your network connection. Retrying...
info There appears to be trouble with your network connection. Retrying...
warning react-scripts > fsevents > node-pre-gyp > hawk > [email protected]: This version has been deprecated in accordance with the hapi support policy (hapi.im/support). Please upgrade to the latest version to get the best features, bug fixes, and security patches. If you are unable to upgrade at this time, paid support is available for older versions (hapi.im/commercial).
warning react-scripts > fsevents > node-pre-gyp > hawk > [email protected]: This module moved to @hapi/sntp. Please make sure to switch over as this distribution is no longer supported and may contain bugs and critical security issues.
warning react-scripts > fsevents > node-pre-gyp > hawk > sntp > [email protected]: This version has been deprecated in accordance with the hapi support policy (hapi.im/support). Please upgrade to the latest version to get the best features, bug fixes, and security patches. If you are unable to upgrade at this time, paid support is available for older versions (hapi.im/commercial).
warning react-scripts > fsevents > node-pre-gyp > hawk > [email protected]: This version has been deprecated in accordance with the hapi support policy (hapi.im/support). Please upgrade to the latest version to get the best features, bug fixes, and security patches. If you are unable to upgrade at this time, paid support is available for older versions (hapi.im/commercial).
warning react-scripts > fsevents > node-pre-gyp > hawk > boom > [email protected]: This version has been deprecated in accordance with the hapi support policy (hapi.im/support). Please upgrade to the latest version to get the best features, bug fixes, and security patches. If you are unable to upgrade at this time, paid support is available for older versions (hapi.im/commercial).
warning react-scripts > fsevents > node-pre-gyp > hawk > [email protected]: This version has been deprecated in accordance with the hapi support policy (hapi.im/support). Please upgrade to the latest version to get the best features, bug fixes, and security patches. If you are unable to upgrade at this time, paid support is available for older versions (hapi.im/commercial).
warning react-scripts > fsevents > node-pre-gyp > hawk > cryptiles > [email protected]: This version has been deprecated in accordance with the hapi support policy (hapi.im/support). Please upgrade to the latest version to get the best features, bug fixes, and security patches. If you are unable to upgrade at this time, paid support is available for older versions (hapi.im/commercial).
warning react-scripts > css-loader > cssnano > postcss-merge-rules > postcss-selector-parser > [email protected]: I wrote this module a very long time ago; you should use something else.
warning react-scripts > eslint > file-entry-cache > flat-cache > [email protected]: CircularJSON is in maintenance only, flatted is its successor.
[2/4] Fetching packages...
info There appears to be trouble with your network connection. Retrying...
error An unexpected error occurred: "https://registry.npmjs.org/pretty-error/-/pretty-error-2.1.1.tgz: getaddrinfo EAI_AGAIN registry.npmjs.org:443".
info If you think this is a bug, please open a bug report with the information provided in "C:\\Users\\sam\\my-app\\yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.
info There appears to be trouble with your network connection. Retrying...

Aborting installation.
  yarnpkg add --exact react react-dom [email protected] --cwd C:\Users\sam\my-app has failed.

Deleting generated file... package.json
Done.

C:\Users\sam>

 

 

说明:因之前设置了npm的注册URL为淘宝的,所以有这个错误。现还原为 https://registry.npmjs.org/,问题解决。命令:npm config set registry https://registry.npmjs.org/

你可能感兴趣的:(CODE)