Error: UNABLE_TO_VERIFY_LEAF_SIGNATURE Phonegap Installation - node.js

I'm trying to install Phonegap in Ubuntu. The installation of NodeJS was successful, however I can't install Phonegap itself. Here is the error output of terminal:
test#test-VirtualBox:~$ sudo npm install -g phonegap
npm http GET https://registry.npmjs.org/phonegap
npm http GET https://registry.npmjs.org/phonegap
npm http GET https://registry.npmjs.org/phonegap
npm ERR! Error: UNABLE_TO_VERIFY_LEAF_SIGNATURE
npm ERR! at SecurePair.<anonymous> (tls.js:1350:32)
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 ERR! reportbug --attach /home/test/npm-debug.log npm
npm ERR! System Linux 3.11.0-14-generic
npm ERR! command "/usr/bin/nodejs" "/usr/bin/npm" "install" "-g" "phonegap"
npm ERR! cwd /home/test
npm ERR! node -v v0.10.15
npm ERR! npm -v 1.2.18
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /home/test/npm-debug.log
npm ERR! not ok code 0
Any help would be appreciated.

I got the same error, given I was behind a corporate firewall/proxy and my connection was passed the proxy's certificate.
In your command line run:
npm config set strict-ssl false
NOTE: that this is not best practice to blindly accept untrusted or invalid SSL certificates, which is what the command does (turn off certificate checking). You can run
npm config set strict-ssl true
to turn it back on.
ref: https://thomashunter.name/blog/npm-ssl-errors/

This can be fixed without disabling strict SSL, however it is non-trivial.
Find the certificates actually being used, likely you're behind a corporate SSL intercepting proxy. You might be able to use a browser, some CLI tool etc. I ended up running certmgr.msc in Windows as the certificates are distributed via Group policy and export as p7b files.
Convert the certificates if necessary, I used openssl tool to convert from p7b to PEM (aka .crt)
openssl pkcs7 -print_certs -inform DER -in /mnt/adam/certs/my-company-root.p7b -outform PEM -out my-company-root.crt
Merge, if there is more than one certificate, into a single PEM file, taking care to order from leaf to root.
cat my-company-leaf.crt my-company-intermediate.crt my-company-root.crt > my-company-single.crt
Configure npm at the certificate file
npm config set cafile my-company-single.crt
(or globally)
sudo npm config set -g cafile my-company-single.crt

running
npm config set strict-ssl false
solved my problem.
I'm using Vagrant (Linux precise32 Ubuntu ), and Windows 7 as host.
Thanks

in case anyone is as clumsy as me, I got UNABLE_TO_VERIFY_LEAF_SIGNATURE on npm install when I forgot to add the git+ before the url of my project.
I had
npm install --save https://myserv.er/my/project-path.git
instead of
npm install --save git+https://myserv.er/my/project-path.git

You can also disable SSL check in your code using node environment variable :
in your index.js file, add :
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
Note that this is not a good habits as it will not try to check the validity of https certificate

Make sure that root has configuration properties.
When using sudo, you're running under the environment configured for root. Root may not have the same node configuration, and may not be aware of your certificates. Try passing your environment configuration to root with -E:
$ sudo -E npm install -g phonegap

It happens to me. It turned out my cooperation proxy restricted the official NPM registry, and returned a blocked HTML warning. Just updated my npm registry to cooperate one, and the problem was solved.

Related

Ignore ssl signage when installing npm locally to let bower restore packages

I'm trying to locally restore a .bower project. In order to do that I've installed Node.js and the next step is: npm install, this produces the following problem:
My collegue's solved this issue by setting the git config property [http] sslVerify to false.
But this doesn't help for me. We're also working behind a proxy, which has been configured in the .bowerrc file. So it should skip certificate verification entirely.
the .bowerrc file also has it's "strict-ssl" setting set on false.
The error says there is a self signed certificate:
[file location]>npm install
npm ERR! Windows_NT 6.1.7601
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\n
node_modules\\npm\\bin\\npm-cli.js" "install"
npm ERR! node v6.9.4
npm ERR! npm v3.10.10
npm ERR! code SELF_SIGNED_CERT_IN_CHAIN
npm ERR! self signed certificate in certificate chain
The full error log can be found in npm-debug.log the first error is at line 230: http://www.filedropper.com/npm-debug
I've also tried the command npm install -g bower, but it produces the same problem. According to the bower install guide I should be able to install Node.js and run npm install -g bower.
The solution was to set the registry to http instead of https.
npm config set registry http://registry.npmjs.org/

error while trying to install npm atob

I was trying to install npm atob in my project;but suddenly it is showing an error now as:
Linux 2.6.23.17-88.fc7
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "atob"
npm ERR! node v5.6.0
npm ERR! npm v3.8.8
npm ERR! code CERT_NOT_YET_VALID
npm ERR! certificate is not yet valid
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR! <https://github.com/npm/npm/issues>
npm ERR! Please include the following file with any support request:
npm ERR! /home/www/project/npm-debug.log
but when i searched the most of them have answered as "Fix your system time"
try to correct your system time before to get a valid certification.
Else try to change the version of nodeJs
sudo npm cache clean -f
sudo npm install -g n
sudo n stable
The 'btoa-atob' module does not export a programmatic interface, it only provides command line utilities.
If you need to convert to Base64 you could do so using Buffer:
console.log(new Buffer('Hello World!').toString('base64'));
Reverse (assuming the content you're decoding is a utf8 string):
console.log(new Buffer(b64Encoded, 'base64').toString());
The error code is CERT_NOT_YET_VALID -certificate is not yet valid, and it refers to ssl certificate.
This should fix this error
$ npm config set strict-ssl false
$ npm config set unsafe-perm true
$ npm config set registry http://registry.npmjs.org/

SSL Error: CERT_UNTRUSTED while using npm command

I am trying to install express framework using npm command but getting following error.
error message is
E:\myFindings\nodejs_programs\node>npm install -g express
npm http GET https://registry.npmjs.org/express
npm ERR! Error: SSL Error: CERT_UNTRUSTED
npm ERR! at ClientRequest.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\request\main.js:409:26)
npm ERR! at ClientRequest.g (events.js:185:14)
npm ERR! at ClientRequest.EventEmitter.emit (events.js:88:17)
npm ERR! at HTTPParser.parserOnIncomingClient [as onIncoming] (http.js:1445:7)
npm ERR! at HTTPParser.parserOnHeadersComplete [as onHeadersComplete] (http.js:111:23)
npm ERR! at CleartextStream.socketOnData [as ondata] (http.js:1356:20)
npm ERR! at CleartextStream.CryptoStream._push (tls.js:396:27)
npm ERR! at SecurePair.cycle (tls.js:751:20)
npm ERR! at EncryptedStream.CryptoStream.write (tls.js:131:13)
npm ERR! at Socket.ondata (stream.js:38:26)
npm ERR! [Error: SSL Error: CERT_UNTRUSTED]
npm ERR! 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 Windows_NT 6.1.7601
npm ERR! command "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "-g" "express"
npm ERR! cwd E:\myFindings\nodejs_programs\node
npm ERR! node -v v0.8.0
npm ERR! npm -v 1.1.32
npm ERR! message SSL Error: CERT_UNTRUSTED
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! E:\myFindings\nodejs_programs\node\npm-debug.log
npm ERR! not ok code 0
help me to sort out
You can bypass https using below commands:
npm config set strict-ssl false
or set the registry URL from https or http like below:
npm config set registry="http://registry.npmjs.org/"
However, Personally I believe bypassing https is not the real solution, but we can use it as a workaround.
npm ERR! node -v v0.8.0
npm ERR! npm -v 1.1.32
Update your node.js installation.The following commands should do it (from here):
sudo npm cache clean -f
sudo npm install -g n
sudo n stable
Edit: okay, if you really have a good reason to run an ancient version of the software, npm set ca null will fix the issue. It happened, because built-in npm certificate has expired over the years.
I had same problem and finally I understood that my node version is old. For example, you can install the current active LTS node version in Ubuntu by the following steps:
sudo apt-get update
curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
sudo apt-get install nodejs -y
Installation instructions for more versions and systems can be found in the following link:
https://github.com/nodesource/distributions/blob/master/README.md
I think I got the reason for the above error. It is the corporate proxy(virtual private network) provided in order to work in the client network. Without that connection I frequently faced the same problem be it maven build or npm install.
If you're behind a corporate proxy, try this setting for npm with your company's proxy:
npm --https-proxy=http://proxy.company.com install express -g
Since i stumbled on the post via google:
Try using npm ci it will be much than an npm install.
From the manual:
In short, the main differences between using npm install and npm ci are:
The project must have an existing package-lock.json or npm-shrinkwrap.json.
If dependencies in the package lock do not match those in package.json, npm ci will exit with an error, instead of updating the package lock.
npm ci can only install entire projects at a time: individual dependencies cannot be added with this command.
If a node_modules is already present, it will be automatically removed before npm ci begins its install.
It will never write to package.json or any of the package-locks: installs are essentially frozen.
Reinstall node, then update npm.
First I removed node
apt-get purge node
Then install node according to the distibution. Docs here .
Then
npm install npm#latest -g
Only recommended if you are running a very old version of node/npm where the certificates have expired or been replaced,
first run npm set ca null
then do your npm install

npm install not working

I just started learning node.js and i have installed node.js along with npm module manager.
I have created a package.json file and from the root directory iam trying to execute npm install command, instead of creating npm_modules folder it throws error like this:
C:\Users\username\Desktop\nodetest>npm install
npm WARN package.json backbone-library#0.0.1 No README.md file found!
npm http GET https://registry.npmjs.org/mongoose
npm http GET https://registry.npmjs.org/express
npm http GET https://registry.npmjs.org/path
npm http GET https://registry.npmjs.org/path
npm http GET https://registry.npmjs.org/express
npm http GET https://registry.npmjs.org/mongoose
npm http GET https://registry.npmjs.org/express
npm http GET https://registry.npmjs.org/path
npm http GET https://registry.npmjs.org/mongoose
npm ERR! Error: connect ETIMEDOUT
npm ERR! at errnoException (net.js:863:11)
npm ERR! at Object.afterConnect [as oncomplete] (net.js:854:19)
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 Windows_NT 6.1.7600
npm ERR! command "D:\\Program Files\\nodejs\\\\node.exe" "D:\\Program Files\\no
ejs\\node_modules\\npm\\bin\\npm-cli.js" "install"
npm ERR! cwd C:\Users\username\Desktop\nodetest
npm ERR! node -v v0.10.0
npm ERR! npm -v 1.2.14
npm ERR! syscall connect
npm ERR! code ETIMEDOUT
npm ERR! errno ETIMEDOUT
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! C:\Users\username\Desktop\nodetest\npm-debug.log
npm ERR! not ok code 0
Iam using Windows 7 OS.
Any ideas ?
Thanks,
Srinivas
This will probably solve your problem:
npm config set proxy proxy-url:port (http:\\proxy-name:port)
npm config set https-proxy proxy-url:port
It was a stuck step on my side,
the following syntax worked for me:
npm config set proxy http:/myproxyserver:port
best regards :)
You may need to use the windows "run as" command (which is equivalent to the *nix "sudo" command) in order to have the correct privileges on your machine.
This link should be helpful: https://superuser.com/questions/42537/is-there-any-sudo-command-for-windows
finally i came to know that my company laptop has proxy restrictions.Once i got the approval for proxy removal it worked.
But still ppl, who ever facing proxy issue in npm install,can try the following method.
Go to C:\Users\YourUserName
Create a file named .npmrc (no need of any prefixname just .npmrc)
Inside that file type the following
proxy = username:password#ip:port (add http:// before username)
That's all.It is perfectly working for me....
The traceroute command will usually tell you where a connection fails and would have lead you straight to the corporate proxy in this case.
Adding to the selected answer
a) "npm config set proxy proxy-url:port (http:\proxy-name:port)
b) npm config set https-proxy proxy-url:port"
make sure you add "http:\\" to your proxy name, and packages downloaded from npm use ssl so try the second option for sure.
If you are working behind a proxy, configure it:
npm config set proxy http://login:pass#host:port
Check the value of your proxy configuration:
npm config get http-proxy
Try again to get your package...

Can't install any packages in Node.js using "npm install"

I'm new to Node.js, and I'm going through a few tutorials.
For some reason, I can't install any new node modules.
I am using:
Mac OSX 10.7.4,
Node v. 0.8.6,
NPM v. 1.1.48.
I run npm install X and I always get a
npm ERR! fetch failed https://registry.npmjs.org/-/X
npm ERR! Error: 404 Not Found
When I actually go to the npmjs registry, I can see the project page, but no matter which tarball link I hit, it's always the same:
{
"error": "not_found",
"reason": "document not found"
}
For example, I tried installing fs by running npm install fs and I get:
npm http GET https://registry.npmjs.org/fs
npm http 200 https://registry.npmjs.org/fs
npm http GET https://registry.npmjs.org/-/fs-0.0.0.tgz
npm http 404 https://registry.npmjs.org/-/fs-0.0.0.tgz
npm ERR! fetch failed https://registry.npmjs.org/-/fs-0.0.0.tgz
npm ERR! Error: 404 Not Found
npm ERR! at null.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/fetch.js:47:16)
npm ERR! at EventEmitter.emit (events.js:115:20)
npm ERR! at WriteStream.flush (fs.js:1514:12)
npm ERR! at fs.close (/usr/local/lib/node_modules/npm/node_modules/graceful-fs/graceful-fs.js:92:5)
npm ERR! at Object.oncomplete (fs.js:297:15)
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 Darwin 11.4.0
npm ERR! command "node" "/usr/local/bin/npm" "install" "fs"
npm ERR! cwd /Users/comocomo/Documents/workspace/nodeTest
npm ERR! node -v v0.8.6
npm ERR! npm -v 1.1.48
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /Users/comocomo/Documents/workspace/nodeTest/npm-debug.log
npm ERR! not ok code 0
I tried fs, fs-extra, express, and formidable, all giving me the same 404 response.
There must be something wrong on my part, I'm pretty sure the whole registry is not broken.
Am I using an old registry? Should I change it in my config file? I honestly would rather not start installing things manually, and I'm sure it's just a small configuration issue.
Thanks!
I found the there is a certificate expired issue with:
npm set registry https://registry.npmjs.org/
So I made it http, not https :-
npm set registry http://registry.npmjs.org/
And have no problems so far.
The repository is not down, it looks like they've changed how they host files (I guess they have restored some old code):
Now you have to add the /package-name/ before the -
Eg:
http://registry.npmjs.org/-/npm-1.1.48.tgz
http://registry.npmjs.org/npm/-/npm-1.1.48.tgz
There are 3 ways to solve it:
Use a complete mirror:
Use a public proxy:
--registry http://165.225.128.50:8000
Host a local proxy:
https://github.com/hughsk/npm-quickfix
git clone https://github.com/hughsk/npm-quickfix.git
cd npm-quickfix
npm set registry http://localhost:8080/
node index.js
I'd personally go with number 3 and revert to npm set registry http://registry.npmjs.org/ as soon as this get resolved.
Stay tuned here for more info: https://github.com/isaacs/npm/issues/2694
Npm repository is currently down.
See issue #2694 on npm github
EDIT:
To use a mirror in the meanwhile:
npm set registry http://ec2-46-137-149-160.eu-west-1.compute.amazonaws.com
you can reset this later with:
npm set registry https://registry.npmjs.org/
source
This error might also occur due to proxy settings, once check that your proxy allow the access to npm commands.
It worked for me quite well.
npm set registry http://85.10.209.91/
(this proxy fetches the original data from registry.npmjs.org and manipulates the tarball urls to fix the tarball file structure issue).
The other solutions seem to have outdated versions.
If you happened to run npm install command on Windows, first make sure you open your command prompt with Administration Privileges. That's what solved the issue for me.
Check under security settings
Allow Apps Downloaded from:
App Store and other identified developers
This was one of the reasons I faced recently.

Resources