Apologies if this is a repeat question, but I am new to this. I have installed nodeJS and am trying to install hardhat. I have a Windows 10 laptop.
I followed the instructions here: https://hardhat.org/tutorial/setting-up-the-environment
I am trying to run the following code:
mkdir hardhat-tutorial
cd hardhat-tutorial
npm init --yes
npm install --save-dev hardhat
Then I get the following errors:
npm ERR! code UNABLE_TO_GET_ISSUER_CERT_LOCALLY
npm ERR! errno UNABLE_TO_GET_ISSUER_CERT_LOCALLY
npm ERR! request to https://registry.npmjs.org/hardhat failed, reason: unable to get local issuer certificate
When I search this online it says to try the following solutions:
npm config set strict-ssl false
OR
npm config set registry http://registry.npmjs.org/
I've done both and rebooted the PC and it doesn't make a difference. Anyone got any ideas of what I can do to resolve this?
Thanks
John
You are running from behind a "deep inspection" web proxy, which issues fake SSL certificates to allow it to inspect your traffic, and although there are probably automated systems to make your browser trust the root CA cert that issues these certificates, npm is not configured to trust that CA.
You should be able to get the CA cert from your browser, the system keychain, or your IT department, and then configure npm to use it with npm config set cafile /path/to/cert.pem
even if you don't know where the corporate certificate is located you can solve it for a single terminal use by running set NODE_TLS_REJECT_UNAUTHORIZED=0 before running the npm commands it will work for the current terminal session.
or you can run setX NODE_TLS_REJECT_UNAUTHORIZED 0 /m once
beware this option as security risks!
to cancel this setting you should run REG delete "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /F /V NODE_TLS_REJECT_UNAUTHORIZED .
the best way to solve the problem will be to find the corporate certificate and run the following command SetX NODE_EXTRA_CA_CERTS "path/to/certificate" /m when you change path/to/certificate by the full path.
Turning off strict ssl: npm config set strict-ssl=false
Changing the registry to http instead of https: npm config set registry http://registry.npmjs.org/
Changing my cafile setting: npm config set cafile /path/to/your/cert.pem
Stop rejecting unknown CAs: set NODE_TLS_REJECT_UNAUTHORIZED=0
Related
I tried to run codes in my hyper-terminal (deleted nodemon and then reinstalled it) but at the end I still can NOT get the version of my nodemon, it says:
"C:\Users\azadk\AppData\Roaming\npm/node_modules/node/bin/node: line 1: This: command not found"
Here’s what I tried to do:
I also tried to set the path of Environment variables to "C:\Program Files\nodejs" but still I can’t get the version.
If you are connected to some sort of VPN or your corporate internet, try to connect to another network and run the call again.
I entered these commands and the problem was resolved:
npm config rm proxy
npm config rm https-proxy
npm config delete http-proxy
npm config delete https-proxy
set HTTP_PROXY=null
set HTTPS_PROXY=null
I'm receiving the following errors when trying to install express:
npm ERR! code ERR_OSSL_PEM_NO_START_LINE
npm ERR! errno ERR_OSSL_PEM_NO_START_LINE
npm ERR! request to https://registry.npmjs.org/express failed, reason: error:0909006C:PEM routines:get_name:no start line
I also had a problem like that... and looking around for various solutions on the internet I tried a few of these:
Try npm install to another repository
Try install another version of node.js
npm set registry http://registry.npmjs.org/
If the above method still fails. You can try these:
Uninstall nodejs from Programs & Features with the uninstaller.
Delete these files:
C:\Program Files (x86)\Nodejs
C:\Program Files\Nodejs
C:\Users\{User}\AppData\Roaming\npm
C:\Users\{User}\AppData\Roaming\npm-cache
C:\Users\{User}\.npmrc (and possibly check for that without the . prefix too)
Reboot, for good measure
Try too install node.js again
Try too nmp install to destination repository
Good luck... with what I mentioned above, I was able to solve the problem with my setup.
I experienced this issue and based on the error message, I noticed the certificate (.crt) and the private key (.pem) files I have in the ssl folder needed to have this lines before the start and at the end of the key contents:
-----BEGIN RSA PRIVATE KEY-----
Your key contents go here for .pem file
-----END RSA PRIVATE KEY-----
The same is required for the certificate file and missing either generates the same error:
-----BEGIN CERTIFICATE-----
Your certificate contents go here for .crt file
-----END CERTIFICATE-----
Do the following :
Delete the following mention
npm cache clean -f
C:\User\user\appdata\roaming\npm-cache
C:\User\user\appdata\roaming\npm
C:\User\user\appdata\Local\Temp
C:\programefile\nodejs
delete node version manager (nvm) is their
type where node on cmd if it shows node js path means node js is properly not uninstalled
delete node js and npm path from environment variable
go to this much address C:\User\user them right click on empty space and go to property and tick on hidden in order to get .npmrc file and delete all reated to it
delete other version of node js if installed
after doing this much restart your pc and then install new latest recommended version of node js. After installed the node js run node -v to check version you installed and npm -v for npm version
Type this command
npm set registry http://registry.npmjs.org/
and after that try again
npm install express
as per this issue it is a certificate related problem
This process worked for me:
Setting the registry with: npm set registry http://registry.npmjs.org/
Retrying the install with npm install express
Type this commands:
npm set registry http://registry.npmjs.org/
and after that try again
npx create-react-app app_name
it's work for me
At my company, there is an auto signed ssl certificate. So they're some npm packages that cannot be installed because of it.
I already add strict-ssl=false in .npmrc or --strict-ssl=false command args.
It works for some packages but some doesn't seems to take in charge this option.
For exemple, I tried to install Cypress :
Command :
npm i cypress --save-dev --strict-ssl=false
Error logs :
> cypress#3.4.0 postinstall /Users/mchoraine/Documents/Workplace/SAMSE/rechercheproduit/rechercheproduit-front/node_modules/cypress
> node index.js --exec install
Installing Cypress (version: 3.4.0)
✖ Downloading Cypress
→ Cypress Version: 3.4.0
Unzipping Cypress
Finishing Installation
The Cypress App could not be downloaded.
Please check network connectivity and try again:
----------
URL: https://download.cypress.io/desktop/3.4.0?platform=darwin&arch=x64
Error: self signed certificate in certificate chain
----------
Platform: darwin (18.6.0)
Cypress Version: 3.4.0
Problem seems to occur only for packages with postinstall
The smartest things would be to change the SSL certificate but unfortunately it can't be done.
So are you aware of an alternative to bypass certificat verification on npm postinstall ?
Thanks in advance for your proposal.
Get a copy of your company's certificate, then set the NODE_EXTRA_CA_CERTS environmental variable to point to it before you run the npm commnand:
export NODE_EXTRA_CA_CERTS=path/to/certificate.crt
The post-install script is a separate node program, so the npm flag doesn't affect it.
Credit goes to "zerdos" who posted this solution on a related GitHub issue: https://github.com/cypress-io/cypress/issues/1401#issuecomment-393591520
For me the following solution worked.
OS - windows 10
Terminal - git bash
Run these commands before installing cypress.
setx HTTP_PROXY <your company proxy url>
setx NODE_EXTRA_CA_CERTS <path to cerm.pem file>
These will be set as environment variables in your system for any future use.
You can always get rid of them anytime if you do not need them.
0
In my company I can't download the node modules via npm, because the connection is being refused. We use a Zscaler with a .pac config file. I tried to configure the proxy via various tutorials
Is there a way to make npm install (the command) to work behind proxy?
https://www.jhipster.tech/configuring-a-corporate-proxy/
but I don't get it to work. When I type
npm --proxy http://username:password#cacheaddress.com.br:80 install packagename
it tells me "event not found", when I type the password. If I leave the password field empty, I get
npm ERR! 418 I'm a teapot - GET http://registry.npmjs.org/electron - got unknown host (registry.npmjs.org:80)
I'm in an environment where I am required to run a local proxy, and I am unable to install node-sass. When I try the following:
npm install -g node-sass
I get an error:
Cannot download "https://github.com/sass/node-sass/releases/download/v4.5.3/win32-x64-48_binding.node": tunneling socket could not be established, cause=read ECONNRESET
I have already installed cntlm and configured it correctly. To verify I use the porxy server to access internet and it works fine.
The following environment variables are set
http_proxy -> http://localhost:3128
https_proxy -> http://localhost:3128
Have also added the following to my .npmrc
https-proxy=http://localhost:3128
http-proxy=http://localhost:3128
proxy=http://localhost:3128
Also tried by adding slashes to the end but the result is the same.
Any clues and help would be appreciated since I have no idea how to resolve this.
Additional details:
node -v
v6.11.4
npm -v
5.5.1
The workaround I found was to download the node-sass file from https://github.com/sass/node-sass/releases/download/v4.5.3/win32-x64-48_binding.node and then set the sass-path to the binaries downloaded:
SET_SASS_BINARY_PATH = C:\..\..\
and then doing
npm install -g node-sass
worked for me.