Getting error while installing npm modules on host system via vagrant - node.js

I am accessing ubuntu Virtual Machine from my host via vagrant and facing issues in npm module installations.
Scenario 1: When I try to do npm install directly on my ubuntu VM via vagrant I get error like :
npm ERR! ETXTBSY: text file is busy, rename '/home/vagrant/workspace/TruckLease-network/node_modules/bn.js/package.json.1931599852' -> '/home/vagrant/workspace/TruckLease-network/node_modules/bn.js/package.json'
Also gets multiple warnings for various modules giving same error - text file is busy.
I tried adding below to my vagrant file but did not work :
config.vm.provider "virtualbox" do |v| v.customize ["setextradata", :id, "VBoxInternal2/SharedFoldersEnableSymlinksCreate/v-root", "1"] end
Scenario 2 : Then I tried to run 'npm install' on windows system directly , it worked with few warnings. Then I did run npm server to launch the application , that also run successfull. But when I hit the application with a get request I get Error :
Original error: Cannot find module '/home/vagrant/workspace/TruckLease-network/node_modules/grpc/src/node/extension_binary/node-v57-linux-x64-glibc/grpc_node.node'
Please suggest where should I exactly run 'npm install' and let me know if there are any pre or post steps for running npm install.
Thanks,
Kalyani

If running npm install on a windows host and then running on Vagrant, you might try npm install --no-bin-links

Related

npm command in VM

I have successfully installed the version of nodejs 14.18 in both in my host machine and VM. After some troubleshooting I manage to make javascripting work in my host machine however when I type javascripting in VM, it says command not found.
ERROR Message
anyone know why this message is displayed any help would be appreciated
I use vagrant as VM and it is required.
npm install -g javascripting attempts to install the module globally, which requires sudo elevation.
If you just want to install the module locally, run npm install javascripting without the -g parameter

Installing Angular CLI with npm install fails

I am new to AngularJS, just started an online course.
I am trying to install angular CLI on my computer at work running Windows 7.
I opened command line as administrator and running npm install -g #angular/cli. Installation starts and after a few minutes I get an error:
I see the notification "operation not permitted", but I am the administrator of the computer and the command line I run as administrator.
What am I doing wrong?
The same installation I did on my laptop at home and it was successful.
I am checking with our IT support about other possible causes and will appreciate any help.
This is not a duplicate of Fail to install npm package “npm ERR! errno -4048” or npm install -g angular-cli fails.
Ignoring the error and running gn -v I get the following:
Is this correct? Was Angular CLI installed?
These issues are because of the company proxy settings.
Check with your admin to get the proxy for http or https.
It will be something like this:
http_proxy = http://http.myproxy.com:8000
https_proxy = http://http.myproxy.com:8000
Replace myproxy with the name of company proxy.
Then go to the command prompt and run the following command to set the proxy. Later you can run any command like npm install -g #angular/cli to run. It will work
npm config set proxy http://http.myproxy.com:8000
npm config set https-proxy http://http.myproxy.com:8000
That fsevents library has peculiarities on Windows. So I suggest you ignore the error message and run ng -v from the command prompt to confirm you got the Angular CLI libraries installed.
You need to run the npm commands on node.js command prompt but not on windows command line.
Workaround: install git bash on windows.
As the error message suggest, you don't have some permissions to execute your command.
Depending on your system, you should run the command as an administrator.
Also, don't mix AngularJS (the first Angular framework) and Angular (also known as Angular 2, 4 and 5 now) . They are radically different in their syntax and uses.
Run below command and try installing angular cli again.
npm cache clean -f
This worked for me manytimes.

npm install issue with proxy

I have installed NodeJS in my machine and when i try to run the command npm install via the command prompt then the network is blocking to download the node_modules into my machine. So strangely when i use the npm install command, it shows the below message along with some other error messages: npm ERR! network connect ETIMEDOUT 151.101.0.162:443.
So with this issue i have raised to out network team that i am getting this error then they said they will open this IP for my system and strangely what happened next is when they have opened this particular IP address for my system i got the same error with the IP address got changed to npm ERR! network connect ETIMEDOUT 151.101.8.162:443.
So what my question is if the command prompt says like this then how can i develop the Angular 4 app in my machine. Is there any solution to overcome this? Can anybody provide any inputs on this issue.

Using yeoman in VM causes error...

I am successfully running this on Linux so this is pure Windows problem. Running vagrant fedora box in windows 7 using nvm (node 0.10.35) give me ERR! tar.unpack untar error starting with grunt-contrib-imagemin module.
Addressed issues ran as non sudo as it was suggested in numerous posts. As my installation on Linux flawlessly installs on Windows I run into issues after running yo webapp
vagrant up vagratn ssh nvm use 0.10.35
yo webapp on windows I get these starting errors
first error:
tar.unpack untar error /home/vagrant/.npm/set-immediate-shim/1.0.0/package.tgz second verbose stack error:
EPERM, open '/home/vagrant/workspace/webapp/node_modules/grunt-contrib-imagemin/node_modules/imagemin/node_modules/imagemin-jpegtran/node_modules/jpegtran-bin/node_modules/bin-build/node_modules/download/node_modules/download-status/node_modules/object-assign/package.json'
and then it goes crazy on grunt-contrib-imagemin.
I am aware of symlink issues in VM and heard of some long paths issues with grunt-contrib-imagemin but I have no direction how to continue debugging.
node -v v0.10.35 npm -v 2.1.17 yo -v 1.3.3 bower -v 1.3.12 grunt --version grunt-cli v0.1.13 Any help is appreciated..
May not be ideal, but I was able to get this working by giving Vagrant user ownership of my project directory.
sudo chown -R vagrant:vagrant /link/to/project

npm install hangs

This is my package.json:
{
"name": "my-example-app",
"version": "0.1.0",
"dependencies": {
"request": "*",
"nano": "3.3.x",
"async": "~0.2"
}
}
Now, when I open the cmd and run npm install, the install hangs. What am I doing wrong?
I had the same problem. The reason - wrong proxy was configured and because of that npm was unable to download packages.
So your best bet is to the see the output of
$ npm install --verbose
and identify the problem. If you have never configured proxy, then possible causes can be
Very outdated npm version.
Some problem with your internet connection.
Permissions are not sufficient for npm to modify files.
I was having the same problem. I tried a
npm config set registry http://registry.npmjs.org/
to turn off https. I also tried
npm set progress=false
to turn off the progress bar (it has been reported to slow down downloads).
The problem was with my network driver. I just needed to reboot and the lag went away.
You can try deleting package-lock.json and running npm install afterwards.
This worked for me.
I had the same issue on macOS, after some time struggling and searching around, this answer actually solved the issue for me:
npm config rm proxy
npm config rm https-proxy
npm config set registry http://registry.npmjs.org/
On MacOS, I was able to solve this by
networksetup -setv6off Wi-Fi
After installing, you can revert to the original configuration with
networksetup -setv6automatic Wi-Fi
Updating npm helped me on Mac OS. Use the command:
sudo npm install -g npm#latest
I am behind a corporate proxy, so I usually use an intermediate proxy to enable NTLM authentication.
I had hangs problem with npm install when using CNTLM proxy. With NTLM-APS (a similar proxy) the hangs were gone.
npm cache clear --force has fixed this issue for me in the past.
Furthermore, when running npm install on an air-gapped network (by the way, I provide a description about how to do this with Verdaccio), I had an issue where the install would hang at the very end. Turning off auditing (i.e. npm set audit false) on the machine on the air-gapped network resolved this issue.
While your mileage may vary, running npm cache verify fixed the issue for me.
It was strange but I guess I was just being impatient ran -> npm install --verbose and saw there was progress but it was just really slow!!! All I needed was patience :D
When your ssh key is password protected run ssh-add. npm probably hangs somewhere asking for your password.
Remove node_modules & package-lock.json from previous npm install and install again
rm -rf node_modules package-lock.json
npm install
or
If npm install loader is stuck and then pops up with..
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/jest failed, reason: unable to get local issuer certificate"
then,
npm config set strict-ssl false
npm install
or
Follow to uninstall Node.js and install properly
https://www.geeksforgeeks.org/how-to-completely-remove-node-js-from-windows/
https://coding-boot-camp.github.io/full-stack/nodejs/how-to-install-nodejs
I personally had this issue and did all the steps I listed above. My issue was fixed with npm config set strict-ssl false
The registry(https://registry.npmjs.org/cordova) was blocked by our firewall. Unblocking it fixed the issue.
With due respect to all the answers, I switched to a different network and it worked for me.
Surprisingly just restarting my computer and running npm install again worked for me
Incase its useful to others, the following is what worked for me:
On my machine, although npm proxy was set correctly, npm install waits forever doing something like sill extract. Re-trying npm install waits forever on the same package again and again.
After waiting for a long timeout, npm install printed an error message implying that git was trying to fetch something.
The problem vanished after configuring git proxy using the below command:
git config --global http.proxy https://proxy-server:port
Note the https in the value of http.proxy without which the configuration did not take effect. Proxy server settings (http / https / port) might vary for users; hence its worth spending a bit of time experimenting with npm and git proxy server settings.
This method is working for me when npm blocks in installation Package for IONIC installation and ReactNative and another package npm.
You can change temporary:
npm config set prefix C:\Users\[username]\AppData\Roaming\npm\node_modules2
Change the path in environment variables. Set:
C:\Users[username]\AppData\Roaming\npm\node_modules2
Run the command to install your package.
Open file explorer, copy the link:
C:\Users[username]\AppData\Roaming\npm\node_modules
ok file yourpackage.CMD created another folder Created "node_modules2" in node_modules and contain your package folder.
Copy your package file CMD to parent folder "npm".
Copy your package folder to parent folder "node_modules".
Now run:
npm config set prefix C:\Users\[username]\AppData\Roaming\npm
Change the path in environment variables. Set:
C:\Users[username]\AppData\Roaming\npm
Now the package is working correctly with the command line.
I'm not sure if your problem is being caused by the same reason that mine was, but I too was experiencing a hanging "npm install" and was able to fix it.
In my case, I wanted to install typescript locally in the project:
npm i typescript --save-dev
For some reason this was conflicting with a global install of typescript that I had, and the shell was just hanging forever instead of finishing or erroring...
I fixing it by first removing the globally installed typescript with the -g global flag:
npm uninstall typescript -g
After doing this the first command worked! 👍
I had npm hanging on installation of electronjs on Windows 10. I reinstalled and still it was hanging. But I noticed it got installed on another desktop in the same network. So finally I found the culprit. The issue was caused by Bitdefender free edition. There was no warning by the antivirus but it was blocking it silently. Even the console was not closing once the installation starts as it kept hanging. Disable antivirus/firewall if its on Windows and make sure network is open as npm does not seem to have a proper way of communicating network blocks and will keep proceeding indefinitely.
I've hit this problem a couple times.
When I was on VPN, I pressed Ctrl-C and disconnected from the VPN. Then npm install worked.
When I wasn't on VPN, I pressed Ctrl-C and connected to the VPN. Then, again, npm install worked.
For anyone on MacOS (I'm on Mojave 10.14), the following helped me out:
https://github.com/reactioncommerce/reaction/issues/1938#issuecomment-284207213
You'd run these commands
echo kern.maxfiles=65536 | sudo tee -a /etc/sysctl.conf
echo kern.maxfilesperproc=65536 | sudo tee -a /etc/sysctl.conf
sudo sysctl -w kern.maxfiles=65536
sudo sysctl -w kern.maxfilesperproc=65536
ulimit -n 65536
Then try npm install once more.
check your environment variables for http and https
The existing entries might be creating some issues. Try deleting those entries.
Run "npm install" again.
I just turn off my windows firewall and it worked for me.
You can also try different versions of npm.
Check your .npmrc file for a registry entry (which identifies a server acting as a package cache.)
For me, npm install would hang partway through, and it was because of a old / non-responsive server listed in my .npmrc file. Remove the line or comment it out:
>cat ~/.npmrc
#registry=http://oldserver:4873
(And/or check with your IT / project lead as to why it's not working ;)
install nvm (Node Version Manager) and downgrade node version from 14 to 12 solved the issue in my case
Uninstalling and installing node and npm worked for me. I'm using Ubuntu 20.04.1 LTS
In my case npm install was hanging because it was waiting for me to input a password to my ssh key while cloning from git repository. There was no prompt and I realized this might be the case when I typed random character and nothing was echoed back. In my case I had to look at package.json file and clone locally repositories listed there. Then I updated package.json and changed paths of those git repositories to my local paths. After doing this everything else was installed without further errors.
On windows i suddenly had the same issue and tried all of the above, but the final solution for me was to switch off the ransomware protection which I had activated. It somehow doesn´t go well along with npm
I was having this error because I was running npm in a (docker) container in WSL2, and docker in WSL2 was configuring the wrong nameservers in the containers, making the container unable to resolve hosts.
To see if your container (or even your host) can resolve hosts, you can try running: curl https://github.com. In my case I received curl: (6) Could not resolve host: github.com.
The error in the docker container doesn't happen if I don't use the default bridge, instead I used a custom bridge and defined the container with it, in which case the resolv.conf file ends up with the correct nameserver:
$ cat /etc/resolv.conf
nameserver 127.0.0.11
options ndots:0
The ip 127.0.0.11 corresponds to the docker DNS server, solving the problem in my case.
If you aren't running npm in a container, your issue may still be related to some misconfigured resolv.conf file (if you are in a Linux machine, or in Windows with WSL/WSL2).
In case anyone else encounters this, I left the npm install to run for long enough, and then the Jest extension crashed (v4.2.1), at which point the npm install completed successfully.
The Jest configuration seems to show that a test auto-watch feature was enabled. I haven't changed any Jest settings as far as I'm aware, so this must be out-of-the-box functionality.

Resources