npm giving UNABLE_TO_GET_ISSUER_CERT_LOCALLY - npm

I'm using Amazon Linux on AWS EC2, using npm version 1.3.6 and node version 0.10.42 (ancient, but upgrading is risky at the moment). It's worth noting that there is no proxy between this machine and the internet.
When running npm install, it's throwing me this error:
npm ERR! fetch failed https://registry.npmjs.org/fibers/-/fibers-1.0.13.tgz
npm ERR! Error: UNABLE_TO_GET_ISSUER_CERT_LOCALLY
npm ERR! at SecurePair.<anonymous> (tls.js:1381:32)
npm ERR! at SecurePair.emit (events.js:92:17)
npm ERR! at SecurePair.maybeInitFinished (tls.js:980:10)
npm ERR! at CleartextStream.read [as _read] (tls.js:472:13)
npm ERR! at CleartextStream.Readable.read (_stream_readable.js:341:10)
npm ERR! at EncryptedStream.write [as _write] (tls.js:369:25)
npm ERR! at doWrite (_stream_writable.js:226:10)
npm ERR! at writeOrBuffer (_stream_writable.js:216:5)
npm ERR! at EncryptedStream.Writable.write (_stream_writable.js:183:11)
npm ERR! at write (_stream_readable.js:602:24)
npm ERR! at flow (_stream_readable.js:611:7)
npm ERR! at Socket.pipeOnReadable (_stream_readable.js:643:5)
npm ERR! If you need help, you may report this log at:
npm ERR! <http://github.com/isaacs/npm/issues>
npm ERR! or email it to:
npm ERR! <npm-#googlegroups.com>
npm ERR! System Linux 4.9.51-10.52.amzn1.x86_64
npm ERR! command "node" "/usr/bin/npm" "install"
npm ERR! cwd /home/meteor-testing/Meteor_Server_Production/bundle/programs/server
npm ERR! node -v v0.10.42
npm ERR! npm -v 1.3.6
It's not just the fibers package, it's all of the requests to https://registry.npm.org erroring out.
As far as I can tell, this error means that the certificate sent by the npm registry server could not be verified against the installed set of root certificates.
I searched around, and found this "solution":
npm config set strict-ssl false
This solves the immediate problem, but makes package installations insecure.
A similarly bad alternative is:
npm config set registry http://registry.npmjs.org/
This seems to work for some requests, but most of them (indirect dependencies maybe?) get rewritten to https anyway.
If I run
curl https://registry.npmjs.org/fibers/-/fibers-1.0.13.tgz
from this machine, it works fine. So maybe npm is using the wrong set of root certs? I can find out what curl is using:
curl -vv https://registry.npmjs.org/type-of/-/type-of-2.0.1.tgz >/dev/null
...
* Connected to registry.npmjs.org (104.16.23.35) port 443 (#0)
* Initializing NSS with certpath: sql:/etc/pki/nssdb
* CAfile: /etc/pki/tls/certs/ca-bundle.crt
I did
yum update ca-certificates
to make sure that this file was up to date. Did not help.
So my next attempt was to point npm at this bundle too:
npm config set cafile /etc/pki/tls/certs/ca-bundle.crt
But this does not help either; still getting the same error.
How to make npm work, without compromising security?

The cafile option was added later, and is not available in my version of npm. It only looks at the ca option, which is set to this by default:
npm config get ca
[ '-----BEGIN CERTIFICATE-----\nMIIChzCCAfACCQDauvz/KHp8ejANBgkqhkiG9w0BAQUFADCBhzELMAkGA1UEBhMC\nVVMxCzAJBgNVBAgTAkNBMRAwDgYDVQQHEwdPYWtsYW5kMQwwCgYDVQQKEwNucG0x\nIjAgBgNVBAsTGW5wbSBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkxDjAMBgNVBAMTBW5w\nbUNBMRcwFQYJKoZIhvcNAQkBFghpQGl6cy5tZTAeFw0xMTA5MDUwMTQ3MTdaFw0y\nMTA5MDIwMTQ3MTdaMIGHMQswCQYDVQQGEwJVUzELMAkGA1UECBMCQ0ExEDAOBgNV\nBAcTB09ha2xhbmQxDDAKBgNVBAoTA25wbTEiMCAGA1UECxMZbnBtIENlcnRpZmlj\nYXRlIEF1dGhvcml0eTEOMAwGA1UEAxMFbnBtQ0ExFzAVBgkqhkiG9w0BCQEWCGlA\naXpzLm1lMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDLI4tIqPpRW+ACw9GE\nOgBlJZwK5f8nnKCLK629Pv5yJpQKs3DENExAyOgDcyaF0HD0zk8zTp+ZsLaNdKOz\nGn2U181KGprGKAXP6DU6ByOJDWmTlY6+Ad1laYT0m64fERSpHw/hjD3D+iX4aMOl\ny0HdbT5m1ZGh6SJz3ZqxavhHLQIDAQABMA0GCSqGSIb3DQEBBQUAA4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HvBN91i0ZJsumB9iOQct+R2UTjEqUdOqCsukNK1OFHrwZyKarXMsh3o\nwFZUTKiL8IkyhtyTMr5NGvo1dbU=\n-----END CERTIFICATE-----\n' ]
I didn't check where this default came from, but I'm guessing it's hardcoded and rather outdated.
Okay, so let's just convert our system-wide CA bundle into a setting in the format that ca expects:
cat /etc/pki/tls/certs/ca-bundle.crt | \
awk 'cert { cert = cert "\\n" $0 }
/-----BEGIN CERTIFICATE-----/ { cert = $0 }
/-----END CERTIFICATE-----/ {
printf "ca[] = \"%s\"\n", cert;
cert = ""
}'
> ~/.npmrc
If it's stupid but it works, it ain't stupid.

Related

How to install npm live-server?

I am getting the following errors on trying to install npm live-server.
Can someone help.
C:\Users\kacho\Desktop\Web Development\Background Gradient\background-generator>npm install -g live-server
npm ERR! code EPROTO
npm ERR! errno EPROTO
npm ERR! request to https://registry.npmjs.org/live-server failed, reason: write EPROTO 10472:error:1408F10B:SSL routines:ssl3_get_record:wrong version number:c:\ws\deps\openssl\openssl\ssl\record\ssl3_record.c:332:
npm ERR!
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\kacho\AppData\Roaming\npm-cache\_logs\2020-04-29T15_34_35_575Z-debug.log
This error appears to be SSL related:
write EPROTO 10472:error:1408F10B:SSL routines:ssl3_get_record:wrong version number:c:\ws\deps\openssl\openssl\ssl\record\ssl3_record.c:332:
npm ERR!
Perhaps you could try setting your registry as follows and reinstalling the live-server library like so:
npm config set registry https://registry.npmjs.org/
npm i live-server
As this action ensures you're connecting to npmjs with ssl.
If this doesn't work, you could try removing the ssl requirement and connecting to npmjs as follows:
npm config set registry http://registry.npmjs.org/
npm i live-server
Lastly, if neither of the above mentioned actions work (use at your own discretion) you could disable the ssl requirement altogether by doing the following:
npm config set strict-ssl false
npm i live-server
Hopefully that helps!

Not able to change npm proxy settings

I was trying to install ExpressJs from npm was using the command:
npm i express
But I got the following error:
npm ERR! Linux 4.15.0-50-generic
npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "i" "express"
npm ERR! node v8.10.0
npm ERR! npm v3.5.2
npm ERR! code ECONNRESET
npm ERR! network tunneling socket could not be established, cause=connect ETIMEDOUT 10.7.0.1:8080
npm ERR! network This is most likely not a problem with npm itself
npm ERR! network and is 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! Please include the following file with any support request:
npm ERR! /home/akhil/npm-debug.log
I suspect it is a proxy error. I use previously working under proxy (mentioned in the error 10.7.0.1:8080) but now I didn't want the proxy and was trying to remove it, for the I have tried the commands:
npm config rm proxy
npm config rm https-proxy
I have also tried adding -g to the above commands
Also I have used,
set HTTP_PROXY=null
set HTTPS_PROXY=null
When I use the command
npm config ls -l
It shows both proxy and https-proxy equal to null. But it seems the proxy has not actually changed looking at the error.
Any help on how to deal with this error would be appreciated.
First, set your proxy false
npm config set proxy false
After that clean your cache
npm cache clean
If that didn't help you and you are using proxy then try this:
npm config set proxy http://proxyhost:proxyport
npm config set https-proxy http://proxyhost:proxyport

How to add public bitbucket repo in package.json or bower.json

I have a library pushed on bitbucket as public repo. I want its link to used in package.json dependencies object. I have tried various https formats but not one is working.
"library_name": "https://username#bitbucket.org/repo_name.git"
"library_name": bitbucket://bitbucket.com/username/repo_name.git
"library_name": "bitbucket#bitbucket.com:username/repo_name.git#master
Or I can add it in bower.json? I don't want to use it directly like npm install repo_url
The error I get is something like
ECMDERR Failed to execute "git ls-remote --tags --heads https://username#bitbucket.org/dv.keystone.git", exit code of #128 remote: Not Found fatal: unable to access 'https://username#bitbucket.org/reponame.git/': GnuTLS recv error (-110): The TLS connection was non-properly terminated.
remote: Not Found
fatal: unable to access 'https://username#bitbucket.org/repo_name.git/': GnuTLS recv error (-110): The TLS connection was non-properly terminated.
Update:
"lib_name": "https://username#bitbucket.org/team_name/repo_name.git"
It works in bower.json but I need this in package.json to work. If I use it in package.json, it gives this error
npm ERR! addLocal Could not install /tmp/npm-16628-b0121d64/git-cache-cbc9eb1e/7c4c6a5fb3e77723f3866c99fdf0825ba7cc0c5c
npm ERR! Linux 4.13.0-39-generic
npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "install"
npm ERR! node v6.12.3
npm ERR! npm v3.10.10
npm ERR! code EISDIR
npm ERR! errno -21
npm ERR! syscall read
npm ERR! eisdir EISDIR: illegal operation on a directory, read
npm ERR! eisdir This is most likely not a problem with npm itself
npm ERR! eisdir and is related to npm not being able to find a package.json in
npm ERR! eisdir a package you are trying to install.
Did some googling for you - as I wasn't sure myself.
This may work for you:
git+https://bitbucket.org/{user}/{repo}.git
I do not know how to add BitBucket modules in package.json. The way I do add github repo as,
"library-name": "git+https://github.com/user/library-name.git"
So to think about just replacing the github part it should be
"library-name": "git+https://bitbucket.org/user/library-name.git"

Unable to install vue-cli using npm

I have installed the latest version of npm and with that, I am trying to install vue-cli using the command
npm install --global vue-cli
But I am running into issues stated below:
npm ERR! code EPROTO
npm ERR! errno EPROTO
npm ERR! request to http://registry.npmjs.org/vue-cli failed, reason: write EPROTO 101057795:error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol:openssl\ssl\s23_clnt.c:827:
npm ERR!
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\pd0ufv\AppData\Roaming\npm-cache\_logs\2018-02-02T17_02_16_113Z-debug.log
I have set my proxy setting as well using
npm set http-proxy <proxy>
npm set https-proxy <proxy>
but didn't work as well. I am using npm version 5.6.0.
Most of the time this error is because the firewall you're behind doesn't actually support SSL peering but will mimic it if you use their http passthrough, so change your https-proxy definition accordingly:
npm set https-proxy http://example.com
Use following steps :
npm cache clean --force
npm install -g #vue/cli

Npm throws 'must have a URL that starts with http: or https:' when installing #angular2-material packages

I'm installing #angular2-material/core ( or any other module ) with npm wont let me install any of the modules.
npm ERR! Darwin 15.5.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "#angular2-material/core"
npm ERR! node v5.11.1
npm ERR! npm v3.8.6
npm ERR! must have a URL that starts with http: or https:
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR! <https://github.com/npm/npm/issues>
I've tried :
npm set registry https://registry.npmjs.org/ // https
OR
npm set registry http://registry.npmjs.org/ // http
But It wont work , I raised the issue with material guys but they're saying this is my local issue .
This is really killing me , there is no clue how to fix it at all.
https://github.com/angular/material2/issues/720
This is mainly because you've tried multiple registries and now npm is kind of confused , You need to open your .npmrc and remove unnecessary registry paths.
To find your .npmrc :
npm config ls -l | grep config
You will see something like :
userconfig /Users/Yourname/.npmrc
Then open that file with your editor and edit and remove extra unnecessary registries .