Problem re-installing NodeJS and NPM on Windows10 - node.js

I am a novice with node.js and npm. I wanted to use purgecss npm plugin so tried to update and upgrade my node
Downloaded v11.1 and installed it but after that Its broken now and I can't figure out its log file either
Here is the npm-debug.log file with it. Please tell me in simple and plain words how to fix this node installation problem

If your having a problem try to update node.js (I did for 3 days). Try Give NVM (Node Version Manager) a try.
Do the following in this order:
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash
command -v nvm
nvm install node
node -v
node -v will show you that your node.js is updated.

So the problem was that the Environment Paths somehow got messed up on the re-install of Node latest version.
So these are the Environment Variables paths settings that worked for me
Now my settings that worked for me looks like this
USER VARIABLES
SYSTEM VARIABLES

Related

"No version is set for command npm" .tool-versions file missing

I'm attempting to create my react app in VS code. After installing node.js (V 18.12.1), I ran the code to create my app and recieved the following response:
npm create-react-app example
No version is set for command npm Consider adding one of the following versions in your config file at nodejs 16.15.0 nodejs 16.17.0 nodejs 16.17.1 nodejs 16.18.0 nodejs 16.18.1
I attempted the reinstall node.js and believe the issue may be due to the absence of my .tools-version file, but I don't know how to create it.
You can use this
npx create-react-app example
Can see the detail in official document.
This could be because you are using a version of Node.js that does not include the npm command. In this case, you can try installing the npm command by running the following command:
npm install -g npm
or try these.
Verify that Node.js is installed correctly on your system by running the node -v command in a terminal. This should print the version number of Node.js if it is installed correctly.
Check if the npm command is in your system's PATH by running the
which npm command in a terminal. This should print the full path to the npm executable if it is in your PATH.
If npm is not in your PATH, you can add it by modifying your PATH
environment variable. You can do this by modifying your shell's
profile file (e.g., ~/.bashrc, ~/.bash_profile, etc.), or by adding the path to the npm executable to your PATH manually.
If you have multiple versions of Node.js or npm installed on your
system, you may need to update your PATH to point to the correct
version. Alternatively, you can use a version manager such as nvm
(Node Version Manager) to manage multiple versions of Node.js and
npm on your system.
Try out and see!
Came here searching a very similar error. I had just got setup with a version manager, asdf, and installed NodeJS LTS (asdf install nodejs lts) before running an npx command and getting the error below.
No version is set for command npx
Consider adding one of the following versions in your config file at
nodejs 18.12.1
nodejs lts
There's no path at the end of that second line 🤔 but given the error and asdf instructions on setting a version, I configured a NodeJS version in the global .tool-versions file and that solved my issued:
echo "nodejs lts" >> $HOME/.tool-versions
Manu Jo Varghese has some great suggestions for checking your installation and environment! To add:
which node: find NodeJS program in your path
bash or zsh -> check which shell you're in, then check .bashrc or .zshrc files as fits

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.

Updating Nodejs on mac

I am using macOS Big Sur and want to update my Node. However, after downloading its file from the official website and completing its installation, my terminal still shows and uses my previous node version.
Does anyone know how can I overcome this issue?
Thanks
terminal screenshot
I suggest using nvm. It's much simpler and eradicates the headache of updating.
nvm
To do this, you can install nvm. https://github.com/nvm-sh/nvm#installing-and-updating
you will be pasting in the curl command curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
Note: when this is finished running, you should see a line near the bottom which says something like export NVM_DIR="$HOME/.nvm"
Copy and paste this and hit enter.
Then check to make sure you have nvm installed now nvm -v
Nodejs update
After, in the terminal, type: nvm install node (you can also check your current version first with node -v
Run it and then check node version again. It should be updated.
npm
While you're at it, you can also update npm.
Check version npm -v
Update npm install -g npm
This should do it. Let me know if there are any issues. Note: this can all be done in the -zsh shell, no reason to move back to bash.
The error displayed was sudo: n: command not found, which hinted that the binary might have not been successfully installed on your system. You need to check the location of n executable by using which command:
$ which n
Reinstalling n with more verbose debug level may also provide you with better information for troubleshooting.
$ sudo npm install --loglevel verbose -g n
Among possible options to install Node.js on MacOS, n was tested to be less error prone as you can read here. You should be on the right direction with the package manager choice.

npm is not compatible with Node.js

I had node installed in my machine and everything was working fine. During an online course made in 2019, the instructor was using an earlier version of npm (v5.5.1) and advised everyone to use the same version with him for follow up reasons. So I downgraded to v5.5.1 but now I keep getting one same error (incompatibility) for almost all commands. I read some solutions to similar problems here and even tried extra steps but the problem still persists.
I uninstalled node from my system, restarted the system and reinstalled node but the version of npm still remained v5.5.1.
I tried to uninstall npm from the command line npm uninstall -g npm but it threw incompatibility error.
I searched the web for compatible version of node.js for npm v5.5.1 and got node v10.15.1 which I downloaded installed with several system restarts but my node and npm still remain incompatible. Please what can I do?
You should use nvm which is the Node Version Manager, cURL:
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.34.0/install.sh | bash
commands:
nvm install <version> Download and install a <version>
nvm use <version> Modify PATH to use <version>
nvm ls List versions (installed versions are blue)
Helpful reads:
How can the default node version be set using NVM?
How to change node version with nvm

NPM Command Not Found After Installing Node

I am having a very hard time getting the npm command to work, and unfortunately my knowledge of unix isn't good enough to solve this on my own. All I've done is brew install node, and I get the following errors:
When I type npm I get zsh: command not found: npm
Looking into this issue more I found this stack overflow answer:
Command not found after npm install in zsh
Following its advice I tried adding export PATH=/usr/local/share/npm/bin:$PATH to my .zshrc file. Still get the same error when typing npm
I can confirm it is in the path echo $PATH yields /Users/nicholashaley/.rbenv/shims:/Users/nicholashaley/.rbenv/bin:/Applications/Postgres.app/Contents/Versions/9.3/bin:/usr/local/heroku/bin:/usr/local/share/npm/bin:/usr/local/bin:/Applications/Postgres.app/Contents/Versions/9.3/bin:/usr/local/heroku/bin:/Users/nicholashaley/.rbenv/shims:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin
I can also confirm that node has been installed node -v yields v0.12.2
Any ideas? I'm stumped
Not an answer, but maybe a solution...
Uninstall Node via brew: brew uninstall node
Then download Node from https://nodejs.org/en/download/ and install.
npm should then "just work".
I came across to this thread with the same problem but finally below is what worked for me which is without sudo
$ brew update
$ brew uninstall node
$ brew install node
$ chown -R YourUserName /usr/local/lib/node_modules/
$ brew postinstall node #This what the important step
Ok this is what worked for me:
$ brew update
$ brew uninstall node
$ brew install node
$ sudo brew postinstall node #This what the important step
In case this never got solved, this is what worked for me:
brew uninstall node
brew install node
brew doctor and see what needs to be pruned. My problem was there was a non-brew place where I had changed my install location for npm packages because I was trying to get an npm package to install for me. That was a mistake (having forgotten I initially installed node and npm through brew but now brew could no longer reach the npm install directory nor could it change or delete it). So brew prune didn't work even though the symlinks were supposedly deleted but it reminded me that I had changed the npm install location. And that brings us to:
Delete those directories
brew postinstall node
Hope it helps.
I found this article helpful with step-by-step details:
https://www.dyclassroom.com/howto-mac/how-to-install-nodejs-and-npm-on-mac-using-homebrew
Additionally, after all the steps in above article, node was working but my machine was still giving "command not found: npm". I then ran the following two commands and npm was working.
sudo chown -R myusername:myusergroup /usr/local/lib/node_modules
brew postinstall node
Anyone on the LTS release use the following command instead:
brew postinstall node#6
Issue Details in Gist and how I fixed it
1. Installed nodeJs via nvm using Git Bash
2. Installed hyper terminal & WSL
3. Installed Ubuntu (windows Store) & configured zsh shell.
4. Faced the command not found all over in the zsh shell
5. The same commands are working nicely in the bash shell
Tried sourcing the (node, nvm, npm ) paths in the .zshrc and .profile file &
modified the System & Environment Variables in Windows. None of these steps helped me to resolve the issue.
I think the issue is zsh and bash terminals treat things differently. When Installed in bash terminal the default location for the nodeJs in windows will be set to
C:\Users\Program Files\nodejs
The above one is symlinked to C:\Users\<username>\AppData\Roaming\nvm
No matter how much I tried to alias these things in zsh, only node and nvm are working with aliases. npm is failing to locate the necessary lib files.
The only solution that worked for me is Re-installing node in zsh terminal
Removed the node versions installed via nvm in Bash terminal.
Removed the nvm in windows via control Panel
Installed the nvm in the zsh shell
Installed the node latest LTS version from which npm is also installed.
Post Installing the node via nvm in Zsh I observed the following things.
Paths for the node, nvm, npm & npx have been automatically added to the $PATH variable
Node directory is not available neither in C:\Users\Program Files\nodejs
nor the C:\Users\{username}\AppData\Roaming\nvm
Instead it is configured differently at /home/<username>/.nvm/versions/node/v14.15.1/bin/node
This video really helped me in re-installing the node in ZSH: https://www.youtube.com/watch?v=kL8iGErULiw
Usually npm should be found in the same directory as that of the node executable, which can be determined by which node. Check if this directory is part of your PATH. If node was installed through a node version managers such as nodenv and nvm, check the documentation for how to add these executables to the path.
With nodenv, this can be done with:
eval "$(nodenv init -)"

Resources