运行npm install cordova时npm install不起作用 [英] npm install does not work when running npm install cordova

查看:262
本文介绍了运行npm install cordova时npm install不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Ionic框架来构建混合应用程序.根据官方网站,我需要获得Node.js的4.2.4版本,其中包括npm软件包管理器. Ionic需要的依赖项之一是cordova,因此我运行以下命令来获取它

I am using Ionic framework to build hybrid apps. According to the official website, i need to get the version 4.2.4 of Node.js, which includes npm package manager. One of the dependencies needed by Ionic is cordova so that i run the following command to get it

C:\Users\ferrero>npm install -g cordova

然后,控制台记录

npm info it worked if it ends with ok
npm verb cli [ 'C:\\Program Files\\nodejs\\node.exe',
npm verb cli   'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
npm verb cli   'prefix',
npm verb cli   '-g' ]
npm info using npm@2.14.12
npm info using node@v4.2.4
npm verb exit [ 0, true ]
npm info ok
npm info it worked if it ends with ok
npm verb cli [ 'C:\\Program Files\\nodejs\\node.exe',
npm verb cli   'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-  cli.js',
npm verb cli   'install',
npm verb cli   'cordova' ]
npm info using npm@2.14.12
npm info using node@v4.2.4
npm verb config Skipping project config: C:\Users\ferrero/.npmrc.
(matches userconfig)
npm verb install initial load of C:\Users\ferrero\package.json
npm verb readDependencies loading dependencies from C:\Users\ferrero\package.json
npm verb cache add spec cordova
npm verb addNamed "latest" is being treated as a dist-tag for cordova
npm info addNameTag [ 'cordova', 'latest' ]
npm verb addNameTag registry:https://registry.npmjs.org/cordova not in flight; fetching
npm verb request uri https://registry.npmjs.org/cordova
npm verb request no auth needed
npm info attempt registry request try #1 at 16:47:06
npm verb request id 62f85abc5c5b7cd5
npm verb etag "6KQ69KRX02Y8MUJFT56H9DE6N"
npm http request GET https://registry.npmjs.org/cordova
npm info retry will retry, error on last attempt: Error: self signed certificate in certificate chain

从日志中可以看到,npm运行版本2.14.12,它抱怨原因是自签名证书-可能由 https发行://registry.npmjs.org/cordova .所以,为了克服这个问题,我跑了

As you can see from log, npm run version 2.14.12 and it complains that the cause is a self signed certificate - likely issued by https://registry.npmjs.org/cordova. So, to overcome this issue, I run

npm config set registry=http://registry.npmjs.org

然后,在那之后(只是相关部分)

And, after that (just the relevant part)

C:\Users\ferrero>npm install -g cordova

npm verb cache add spec cordova
npm verb addNamed "latest" is being treated as a dist-tag for cordova
npm info addNameTag [ 'cordova', 'latest' ]
npm verb addNameTag registry:http://registry.npmjs.org/cordova not in flight; fetching
npm verb request uri http://registry.npmjs.org/cordova
npm verb request no auth needed
npm info attempt registry request try #1 at 16:59:34
npm verb request id 359f93cb3aa8b76e
npm verb etag "6KQ69KRX02Y8MUJFT56H9DE6N"
npm http request GET http://registry.npmjs.org/cordova
npm http 304 http://registry.npmjs.org/cordova
npm verb headers { 
    date: 'Tue, 26 Jan 2016 18:59:34 GMT', 
    npm verb headers   via: '1.1 varnish', 
    npm verb headers   'cache-control': 'max-age=300', 
    npm verb headers   etag: '"6KQ69KRX02Y8MUJFT56H9DE6N"',
    npm verb headers   age: '263',
    npm verb headers   connection: 'keep-alive',
    npm verb headers   'x-served-by': 'cache-atl6230-ATL',
    npm verb headers   'x-cache': 'HIT',
    npm verb headers   'x-cache-hits': '1',
    npm verb headers   'x-timer': 'S1453834774.362657,VS0,VE1',
    npm verb headers   vary: 'Accept' 
}
npm verb etag http://registry.npmjs.org/cordova from cache
npm verb get saving cordova to C:\Users\ferrero\AppData\Roaming\npm-cache\registry.npmjs.org\cordova\.cache.json
npm verb addNamed "5.4.1" is a plain semver version for cordova
npm verb addRemoteTarball http://registry.npmjs.org/cordova/-/cordova-5.4.1.tgz
not in flight; adding
npm verb addRemoteTarball [ 'http://registry.npmjs.org/cordova/-/cordova-5.4.1.tgz',
npm verb addRemoteTarball   'bc56bc1d3c5387a7926408212dfbce59002f9d76' ]

这一次,它没有任何其他抱怨.取而代之的是,加载指示器(管道字符)不断运行.那么,我应该怎么做才能下载这种依赖关系?

This time, it does not complain anything else. Instead, the loading indicator - a pipe character - keep running and running. So, what should i do in order to download such dependency ?

推荐答案

在这里,我们似乎正在研究两个不同的问题.

We seem to be looking at two distinct issues here.

证书错误很可能是由于出站SSL代理引起的.某人(很可能是您的雇主)正在打开所有SSL流量.要对其进行修复,您需要通过导入使用中的代理的CA证书来告知NPM该证书是可以的.

The certificate error is likely due to an outbound SSL proxy. Someone, most likely your employer, is opening all SSL traffic on the way out. To fix it, you'll need to tell NPM that this certificate is okay by importing the CA certificate of the proxy in use.

npm config set cafile = "/the/certificate/file.pem"

您可能还需要为npm设置代理地址:

You may also need to set the proxy address for npm as well:

npm config set proxy http://proxy.example.com:3128
npm config set https-proxy http://proxy.example.com:3128

根据我的研究,似乎已修复了与节点5.0的不兼容性.该文档似乎已经过时了.

The incompatibility with node 5.0 seems to have been fixed according to my research. The documentation just seems to be out of date.

科尔多瓦(Cordova)中的错误可能是问题所在,它是Q承诺中的缺少方法库,这是科尔多瓦所依赖的.

The bug in Cordova which may have been the issue was a missing method in the Q promises library, which Cordova depends upon.

2015年11月,用户能够在节点5.1.0上成功使用Ionic .

In November 2015 a user was able to use Ionic successfully with node 5.1.0.

这篇关于运行npm install cordova时npm install不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆