NVM - All The Packages I Installed with NPM Suddenly Stops Working - node.js

I installed Node with NVM as I would not like to use sudo for access permission purposes.
I got the installation of nvm, installed node, installed npm and some npm packages.
The next morning I power on my mac and everything is not working anymore.
I guess ~/.nvm/v0.10.33/bin is not on my $PATH, but I'm confused as it was totally working fine yesterday.
P.S., The command nvm still works on my terminal though.

Nvm(nevermind). I got it working by setting the default to my node version by:
nvm alias default v0.10.33
So everytime I open a new terminal, node and other command just works.

Related

Doesn't install NPM when I install a new Node version using NVM

Whenever I update Node with nvm, npm is no longer available.
nvm install 14.19.3 > It says it's also downloading and installing npm.
npm > Error: Cannot find module 'C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js'
Looking in C:\Users\Username\AppData\Roaming\nvm\v14.19.3, the subfolder node_modules is empty. It doesn't seem to have installed npm along with nvm, even though there was no error upon nvm install 14.19.3.
From this post I understand the cause of a problem like this generally is a conflict in the environment variables of the OS (I'm using VSC on a Windows 10 machine).
But I can't find anything wrong there: PATH includes NVM_HOME and NVM_SYMLINK, which respectively point to C:\Users\Username\AppData\Roaming\nvm and C:\Program Files\nodejs.
How can I get this new version of Node to work?
I had to update my nvm for windows version (from 1.1.7 to 1.1.9).
After this I uninstalled the Node version and installed it again with the new nvm version. Now it did install NPM along with Node.
nvm use 14.20.0 (the new Node version I installed) gave an error however:
exit status 5: Access is denied.
Running the terminal / Visual Studio Code with administrator privilages solved this issue and I was able to successfully switch Node versions.
Shouldn't the NVM_SYMLINK point to %AppData%\npm or C:\Users\Username\AppData\npm?
Have you tried to: nvm install-latest-npm or nvm install --latest-npm?
Also check it out this answer as it may help.
Another solution was to just pick another Node version. I am not sure for a particular reason but I used via NVM at least 4 different version and they are all fine. Only the following version 14.17.0 seems buggy.

Why is there a nodejs directory in ubuntu subsysem when nodejs is not installed?

I just installed the ubuntu subsystem.
I have not installed node yet but it has a nodejs directoy under /mnt/c/Program files/nodejs.
The problem is that I can run npm after installing node. It gives me this error:
I uninstalled and reinstalled the linux subsystem, but the directroy is always there. I tried all of the solutions online for dealing with this error but none of them worked.
I can't even remove this directroy because of permissions. Even sudo-ing won't work.
How can i fix this and get npm running?
The folder you’re browsing to is actually your Windows installed Node version.
You’re better off installing nvm or just using nodesource to download and install Node.
NVM is my preference if you’re needing to install multiple versions for dev purposes etc. nvm

Nvm and Node keep going missing upon closing terminal

Hoping you can help me figure out this issue!
I just bought a new MacBook and was getting my development environment set up today. I installed XCode, Brew, NVM, and Git. When I installed Git, I had to change it so it was the first in the path so I could avoid using Apple Git, and I think that severely messed things up.
For some reason, nvm was not showing when I was running:
nvm ls or nvm ls-remote
Yet when I told brew to install nvm, it said it was already installed. OK. Eventually was able to get it sorted out and install node and such.
Fast forward to now, I went to run node in the terminal. Node was not found. Did some research and found that I should not install nvm with homebrew, so I did brew uninstall nvm and brew cleanup and then installed through the recommend github repository.
I ran the necessary commands and added to my PATH, and when I ran command -v nvm, nvm was returned. GREAT. Then I ran the other commands to install Node and I was able to use it, until I closed the terminal.
Now when I reopen the terminal and run node, it returns command not found. Command -v nvm does not return anything too.
Please help - it's been such a headache and I can't seem to figure out whats going on. Every solution I'm finding on Stack Overflow works until I close the terminal.
I was able to figure it out. The command all NVM guides tell you to run in order to start running node was not properly added to .bashrc.
Use these as a reference if you have the same issue as me:
https://itnext.io/nvm-the-easiest-way-to-switch-node-js-environments-on-your-machine-in-a-flash-17babb7d5f1b
.bashrc: Permission denied

npm deletes on its own after closing the ubuntu terminal?

I am running Ubuntu 16.04 Xenial on VirtualBox. The problem is that once I install npm using the command:
nvm install v8.1
then it recognizes commands like npm.
But if I close this particular session of terminal and reopen it again, then it fails to recognize npm command. So everytime I need to use npm, I have to reinstall it for that particular session of terminal. And when I reinstall it using nvm install v8.1, It says,
v8.1.4 is already installed.
Now using node v8.1.4 (npm v5.0.3)
But now it recognizes npm command. What is the problem?
When node is installed via nvm, it's actually expected that you would type nvm use 8 before using node. You shouldn't have to re-install it (and, based on your output, it looks like you didn't).
If you want to default to node v8, you can do that by typing:
nvm alias default 8.1
Note that you may be missing the appropriate .bashrc entry (in your ~/.bashrc file) that loads nvm when your terminal starts up. It should look something like this:
export NVM_DIR="$HOME/.nvm"
. "$NVM_DIR/nvm.sh"

Global npm installs break after restarting terminal

I recently installed node using nvm and had no problems initially with installing globally packages with npm. But then I found that if I close the terminal in which I originally installed the package, I will get "command not found" when attempting to use it.
For example, browser-sync. I closed the terminal after finding that it worked properly. When I opened it up later to continue working on the project I need it for, it turns out that now I get "command not found" in every directory despite installing it globally.
I am running Linux Mint Cinammon 17.3 with the latest version of node and npm.
Any help for this?
I've since solved this problem by:
Completely uninstalling nvm and node.
Reinstalling node using apt-get
Changing npm config prefix to /usr/local
Correctly setting npm permissions
For some reason despite multiple uninstalls/reinstalls and playing with permissions before, it wouldn't work until I deleted all the folders created by node or npm before reinstallment. Weird.

Resources