我在哪里为node.js设置rejectUnauthorized = false

时间:2013-12-11 18:06:46

标签: node.js npm yeoman

我在哪里进入我的安装以完成此项检查:

rejectUnauthorized = false

会阻止:

k@n-mint ~ $ npm install -g yo
npm http GET https://registry.npmjs.org/yo
npm http GET https://registry.npmjs.org/yo
npm http GET https://registry.npmjs.org/yo
npm ERR! Error: Hostname/IP doesn't match certificate's altnames
npm ERR!     at SecurePair.<anonymous> (tls.js:1359:23)
npm ERR!     at SecurePair.EventEmitter.emit (events.js:92:17)
npm ERR!     at SecurePair.maybeInitFinished (tls.js:963:10)
npm ERR!     at CleartextStream.read [as _read] (tls.js:463:15)
npm ERR!     at CleartextStream.Readable.read (_stream_readable.js:320:10)
npm ERR!     at EncryptedStream.write [as _write] (tls.js:366:25)
npm ERR!     at doWrite (_stream_writable.js:219:10)
npm ERR!     at writeOrBuffer (_stream_writable.js:209:5)
npm ERR!     at EncryptedStream.Writable.write (_stream_writable.js:180:11)
npm ERR!     at write (_stream_readable.js:573:24)
npm ERR! If you need help, you may report this log at:
npm ERR!     <http://bugs.debian.org/npm>
npm ERR! or use

尝试

npm set strict-ssl false 

导致与上述相同的错误并尝试:

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

结果

k@k-mint ~ $ npm config set registry http://registry.npmjs.org/
k@k-mint ~ $ npm install -g yo
npm http GET http://registry.npmjs.org/yo
npm http 200 http://registry.npmjs.org/yo
npm http GET http://registry.npmjs.org/yo/-/yo-1.0.5.tgz
npm http 200 http://registry.npmjs.org/yo/-/yo-1.0.5.tgz
npm ERR! Error: EACCES, mkdir '/usr/local/lib/node_modules'
npm ERR!  { [Error: EACCES, mkdir '/usr/local/lib/node_modules']
npm ERR!   errno: 3,
npm ERR!   code: 'EACCES',

编辑2_ _ __ _ __ _ __ _ __ _ __ _ __ _ ___ ----

也试过这个

k@k-mint /etc/init.d $ sudo npm config set registry http://registry.npmjs.org/


k@k-mint /etc/init.d $ npm install -g yo
npm http GET http://registry.npmjs.org/yo
npm http 304 http://registry.npmjs.org/yo
npm ERR! Error: EACCES, mkdir '/usr/local/lib/node_modules'
npm ERR!  { [Error: EACCES, mkdir '/usr/local/lib/node_modules']

1 个答案:

答案 0 :(得分:5)

试试这个:

npm set strict-ssl false

您也可以安装没有https的软件包,因此无需证书

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

npm install -g是全局安装包,您可能需要root权限才能使用全局文件夹:

sudo npm install -g <package>