How to install npm package globally without internet connection? - node.js

I need to install pm2 and pm2-windows-service package globally on a computer without an internet connection. I have tried to save each package as a tarball on my own computer (with internet connection) like this:
npm pack pm2
npm pack pm2-windows-startup
Then I copy both tarball files 'pm2-4.2.3.tgz' and 'pm2-windows-startup-1.0.3.tgz' to the computer without internet connection and try to install globally as follow:
npm i -g pm2-4.2.3.tgz
npm i -g pm2-windows-startup-1.0.3.tgz
But I always have the same error ...
npm ERR! code ENOTFOUND
npm ERR! errno ENOTFOUND
npm ERR! network request to https://registry.npmjs.org/#pm2%2fagent failed, reason: getaddrinfo ENOTFOUND registry.npmjs.org
npm ERR! network This is a problem 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'
Some suggestion to solve that?

According to npm documentation
Global install (with -g): puts stuff in /usr/local or wherever node is installed.
I haven't tried it myself but what I'd try to do is to take the dependency (with all subdependencies) and put it in the directory with your node. Something like <PATH_TO_NODE>/node_modules.
Then take the corresponding file from your local node_modules/.bin and put it in the <PATH_TO_NODE>
If you don't know where your node is installed, you can run this command in the terminal
npm config get prefix
Directories will be different on UNIX systems.

Related

Linux terminal, npm install ETIMEDOUT

I installed nodeJs and npm using nvm, that went perfectly, then I notice that a newer version of npm was available so i try
npm install -g npm#latest
But then it just stays as like that, it's like it does not start never, so I try another command and this happens
npm install -g n
Same thing, noting happens.
Trying and trying I manage to get the following error:
/home/jonathan/.nvm/versions/node/v18.12.1/bin/npx --yes --package #angular/cli ng new untitled --defaults
npm ERR! code ETIMEDOUT
npm ERR! syscall connect
npm ERR! errno ETIMEDOUT
npm ERR! network request to https://registry.npmjs.org/#angular%2fcli failed, reason: connect ETIMEDOUT 2606:4700::6810:1123:443
npm ERR! network This is a problem 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! A complete log of this run can be found in:
npm ERR! /home/jonathan/.npm/_logs/2022-12-28T05_07_38_682Z-debug-0.log
Done
So searching on the internet I found the url npm uses to attempt the installs the following:
registry.npmjs.org <
I tried then:
ping registry.npmjs.org
Same as above, it does nothing, it suppose to show some info every few seconds but nothing happens so y put the url in a browser and it works
{"db_name":"registry","engine":"couch_bt_engine","doc_count":3313520,"doc_del_count":332,"update_seq":31421891,"purge_seq":0,"compact_running":false,"sizes":{"active":69891815727,"external":214417993712,"file":70327402736},"disk_size":70327402736,"data_size":69891815727,"other":{"data_size":214417993712},"instance_start_time":"1672130582611333","disk_format_version":7,"committed_update_seq":31421891,"compacted_seq":31421548,"uuid":"3a4ad341a4111dd254daa731f37b37ae"}
That's what it shows.
So. I don't know what it's going on, I'm not using any proxy or firewall. Need some help here.
Update... I try using wifi not wired connection and it works, so the problem appears to be wired connection
Solution remains on network configuration, as Robert says its not related to programming so I'm marking this as answer. Thank any who try to help

How can I install npm packages when I have a failed network request error?

I'm using a Mac with the zsh terminal, and I have node v16.13.1 on my machine.
I'm trying to install packages, but I haven't been successful. I get the error below, regardless of what package I try to install. I've also tried initializing first using npm -init, but I still get the same result.
npm ERR! code ECONNRESET
npm ERR! errno ECONNRESET
npm ERR! network request to https://registry.npmjs.org/figlet failed, reason: Client network socket disconnected before secure TLS connection was established
npm ERR! network This is a problem 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! A complete log of this run can be found in:
npm ERR! /Users/edgaracuna/.npm/_logs/2022-01-02T16_01_32_283Z-debug.log
How can I resolve this issue to be able to install node packages?
I was unable to recreate the issue, so I think this isn't a problem that you can directly solve. Either you have a firewall issue, or maybe the npm servers were down or broken at the time. Just try again later, reboot your computer or join a different wifi network.

Is there a way to solve ECONNRESET error when using npm? I need to restart the machine to fix it

After using the computer for a while I cant use npm install anymore. If I restart the computer then all gets back to working.
I am using macOS Mojave 10.14.3 with node v11.12.0 and npm 6.9.0.
Tried the solutions here: npm not working - "read ECONNRESET" but no success
npm i faker
npm ERR! code ECONNRESET
npm ERR! errno ECONNRESET
npm ERR! network request to https://registry.npmjs.org/faker failed, reason: read ECONNRESET
npm ERR! network This is a problem 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! A complete log of this run can be found in:
npm ERR! /Users/flaviomelo/.npm/_logs/2019-03-28T12_25_35_242Z-debug.log
It is always possible that for a few minutes, NPM was down - so try again now just in case.
But in general, I would start by trying to find where the problem lies.
Try this:
curl https://registry.npmjs.org/faker
That should produce pages and pages of JSON. If it doesn't, then it's possible that your terminal - for whatever reason - cannot access the internet. Comments below this answer have further steps you can try in debugging this.
If it does produce lots of JSON, then there is a problem in your version of NPM / node. As these seem to be the latest, try downgrading each to see if it's a new bug.
you can try these solutions
Solution 1:
MAC + LINUX
run this command with sudo
sudo npm install -g yo
Windows
run cmd as administrator and then run this command again
Solution 2:
run this command and then try
npm config set registry http://registry.npmjs.org/

NPM, downloads dependencies from wrong URL address

After working with some project, my npm started to download dependencies from wrong address globally:
npm install -g bower
npm ERR! code ETIMEDOUT
npm ERR! errno ETIMEDOUT
npm ERR! network request to http://172.168.1.1/bower failed, reason:
connect ETIMEDOUT 172.168.1.1
npm ERR! network This is a problem 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! A complete log of this run can be found in:
Is there some method to reset download address to default one?
I'm using Windows version of NodeJS
Looks like your registry npm config option points to the wrong location. It must be https://registry.npmjs.org, check it with the following command:
npm config get registry
If your registry is different, use this command to set it correctly:
npm config set registry https://registry.npmjs.org/

Can't install node package even though I'm not using a proxy

I'm (very) new to nodejs and raspberry pi.
I'm trying to install the onoff package for a test project, following this tutorial.
Everything works fine and I've set up a new node project using npm init.
Installing onoff (npm install onoff) however fails.
It says:
npm ERR! network getaddrinfo ENOTFOUND 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'
I've checked using npm config get proxy, this returns null so I don't think this is a proxy issue.
Anyone who can help me with this?
UPDATE:
ping 74.125.224.72returns "network is unreachable"

Resources