使用特定版本的软件包初始化create-react-app

时间:2019-01-22 10:06:57

标签: npm create-react-app

我正在尝试初始化一个create-react-app项目。

不幸的是,当它尝试获取webpack-dev-server@3.1.14时,此操作失败了,因为我公司的内部NPM注册中心已确定3.1.14存在漏洞,因此返回404。

如何初始化create-react-app,并指定它必须使用webpack-dev-server@ 3.1.13

以下是详细输出的最后50行:

...
npm verb get http://myregistry:1234/jest not expired, no request
npm verb afterAdd c:\dev\npm-cache\eslint-plugin-react\7.11.1\package\package.json written
npm verb afterAdd c:\dev\npm-cache\jest\23.6.0\package\package.json not in flight; writing
npm verb correctMkdir c:\dev\npm-cache correctMkdir not in flight; initializing
npm verb cache add spec eslint@5.6.0
npm verb addNamed "5.6.0" is a plain semver version for eslint
npm verb addNameVersion registry:http://myregistry:1234/eslint not in flight; fetching
npm verb get http://myregistry:1234/eslint-plugin-flowtype not expired, no request
npm verb afterAdd c:\dev\npm-cache\jest\23.6.0\package\package.json written
npm verb afterAdd c:\dev\npm-cache\eslint-plugin-flowtype\2.50.1\package\package.json not in flight; writing
npm verb correctMkdir c:\dev\npm-cache correctMkdir not in flight; initializing
npm verb get http://myregistry:1234/webpack-dev-server not expired, no request
npm verb addRemoteTarball http://myregistry:1234/webpack-dev-server/-/webpack-dev-server-3.1.14.tgz not in flight; adding
npm verb addRemoteTarball [ 'http://myregistry:1234/webpack-dev-server/-/webpack-dev-server-3.1.14.tgz',
npm verb addRemoteTarball   '60fb229b997fc5a0a1fc6237421030180959d469' ]
npm verb afterAdd c:\dev\npm-cache\eslint-plugin-flowtype\2.50.1\package\package.json written
npm verb get http://myregistry:1234/babel-core not expired, no request
npm verb get http://myregistry:1234/eslint not expired, no request
npm info retry fetch attempt 1 at 9:58:55 AM
npm info attempt registry request try #1 at 9:58:55 AM
npm http fetch GET http://myregistry:1234/webpack-dev-server/-/webpack-dev-server-3.1.14.tgz
npm verb afterAdd c:\dev\npm-cache\babel-core\7.0.0-bridge.0\package\package.json not in flight; writing
npm verb correctMkdir c:\dev\npm-cache correctMkdir not in flight; initializing
npm verb afterAdd c:\dev\npm-cache\eslint\5.6.0\package\package.json not in flight; writing
npm verb correctMkdir c:\dev\npm-cache correctMkdir not in flight; initializing
npm verb request uri http://myregistry:1234/webpack
npm verb request no auth needed
npm info attempt registry request try #1 at 9:58:55 AM
npm verb etag "3cb43ef0e59f247dfcf5f855611d5749"
npm http request GET http://myregistry:1234/webpack
npm verb afterAdd c:\dev\npm-cache\babel-core\7.0.0-bridge.0\package\package.json written
npm http fetch 404 http://myregistry:1234/webpack-dev-server/-/webpack-dev-server-3.1.14.tgz
npm ERR! fetch failed http://myregistry:1234/webpack-dev-server/-/webpack-dev-server-3.1.14.tgz
npm WARN retry will retry, error on last attempt: Error: fetch failed with status code 404
npm verb afterAdd c:\dev\npm-cache\eslint\5.6.0\package\package.json written
npm http 304 http://myregistry:1234/webpack
npm verb headers { 'x-powered-by': 'Sinopia/1.4.0',
npm verb headers   etag: '"3cb43ef0e59f247dfcf5f855611d5749"',
npm verb headers   'x-status-cat': 'http://flic.kr/p/aXY3dH',
npm verb headers   date: 'Tue, 22 Jan 2019 09:58:55 GMT',
npm verb headers   connection: 'keep-alive' }
npm verb etag http://myregistry:1234/webpack from cache
npm verb get saving webpack to c:\dev\npm-cache\appduv03d1.machine.test.group_4873\webpack\.cache.json
npm verb correctMkdir c:\dev\npm-cache correctMkdir not in flight; initializing
npm verb cache add spec webpack@4.19.1
npm verb addNamed "4.19.1" is a plain semver version for webpack
npm verb addNameVersion registry:http://myregistry:1234/webpack not in flight; fetching
npm verb get http://myregistry:1234/webpack not expired, no request
npm verb afterAdd c:\dev\npm-cache\webpack\4.19.1\package\package.json not in flight; writing
npm verb correctMkdir c:\dev\npm-cache correctMkdir not in flight; initializing
npm verb afterAdd c:\dev\npm-cache\webpack\4.19.1\package\package.json written
npm info retry fetch attempt 2 at 9:59:05 AM
npm info attempt registry request try #1 at 9:59:05 AM
npm http fetch GET http://myregistry:1234/webpack-dev-server/-/webpack-dev-server-3.1.14.tgz
npm http fetch 404 http://myregistry:1234/webpack-dev-server/-/webpack-dev-server-3.1.14.tgz
npm ERR! fetch failed http://myregistry:1234/webpack-dev-server/-/webpack-dev-server-3.1.14.tgz
npm WARN retry will retry, error on last attempt: Error: fetch failed with status code 404

2 个答案:

答案 0 :(得分:0)

显示的错误是什么

简单方法:如果我能得到你

1.create-react-app my-app
2.cd my-app
3.npm我webpack-dev-server@3.1.13
4.如果出现严重漏洞,只需运行npm audit fix进行修复,或运行npm audit以获得详细信息

如果任何依赖项已迁移或存在问题,您将在终端msg中找到解决方案,

答案 1 :(得分:0)

我认为它将起作用

$ npm设置注册表https://registry.npmjs.org

比干净的缓存

$ npm缓存清理 $ npm重建

或者可能是代理服务器问题 尝试其他互联网连接