unable to run npm after installing nodejs in windows 10? - node.js

i downloaded nodejs and installed with node package manager.
After installing when i typed..
node -v
i am getting response as
v.6.11.1
But when i type
npm -v
i am not gettin any response.then when i give ctrl+c to terminate i am getting response as
Terminate batch job(y/n)?
I have tried reinstalling several times but couldnt able to run npm installation.Any help?

I think node js is not installed properly in your system.
Try to reinstall it and then do this process again.

Follow these steps you will get the node and npm installation successful:
download Nodejs from the link https://nodejs.org/en/
download V6.11.1 LTS (long term support)
type npm install -g #angular/cli in the command promt
check the version now by typing npm -v in the command prompt and node -v

It may not installed properly, Reinstall npm
Try this link https://nodejs.org/en/download/package-manager/

Related

Error npm is known not to run on Node.js v10.24.1 and how to fix it, don't update to the latest version?

I run : npm run dev
Error : npm is known not to run on Node.js v10.24.1
I have researched and know the command: npm install -g npm#latest and some other commands to fix the problem
But the problem is that my project is using nodejs 10 so it can't use the latest nodejs. So is there any way to fix the above error. Thank you
UPDATE :
I use nvm to install and manage versions of nodejs. And my OS is macOs
The problem for me was upgrading my global version of npm while on an incompatible version of Node (8.16.1).
I tried to uninstall npm globally but that also didn't work because I could not use the npm command.
To fix it, I used nvm to switch to a compatible version of Node (nvm use 14.0.0 - this can be any version of Node compatible with the npm version you have installed globally). This allowed me to run npm commands so I ran npm uninstall -g npm first of all to remove my global version of npm and then nvm uninstall 8.16.1 to remove my faulty Node version.
I was then able to reinstall Node 8.16.1 (nvm install 8.16.1), and with it came a fresh install of a compatible npm version.
I happen to work on a project that builds on node 10 as well.
More details would have been helpful to understand the problem better but I suspect it's a compatibility issue.
Try these:
Download and install the latest version of nodejs.
Open you terminal and verify you have the latest version using node -v. Verify your npm version too using npm -v.
Since you have nvm installed, run nvm install 10, then nvm use 10.
Verify your versions again. In my case, node is v10.24.1 & npm is 6.14.12.
Start your app using npm run dev. Please check you package.json to be sure you are using the right startup command.
I was having the same problem, I ran the command and it solved the problem with NPM
sudo n latest
Node: v10.19.0
NPM: 8.9.0
Reference
I performed an upgrade of npm by mistake and run into the same issue.
The only way to solve for me was to delete the two following directories:
C:\Users\<username>\AppData\Roaming\npm
C:\Users\<username>\AppData\Roaming\npm-cache
npm is known not to run on Node.js v10.24.1 comes when normally people upgrade the version of npm to latest or recent ones, but when it comes to node 10 version you can use npm version 6.4.1 or 6 series. Normally npm 6.4.1 will come with node js 10.24.1 but if you have given any npm update cmd you need to go to C:\Users\username\AppData\Roaming and delete npm and npm cache folders then delete npm folders in C:\Users\username\AppData\local then check the npm version using npm -v. After doing this install the angular version
Thanks #Oduola Olumide Sunday for the response. I have followed your way but still not solved the problem.
And I fix it by removing the latest nodejs version and using the normal node v10.24.1
enter link description here ->
I removed the latest nodejs version with this
This error happens when your npm version is not what you think it is...
For instance, you download a nodejs pkg and install. Run node -v, npm -v... npm -v provides the error that brought you here.
This means your aren't using the version the nodejs pkg installed, but some remnant somewhere- from other install attempts.
In my case, I had a Homebrew installed version of npm that I didn't realize existed.
You can find the locations, at least on mac, using the 'where' command.
where npm
Which will return path(s) of your npm locations. Find the one that doesn't belong and give it the boot.
Then your npm -v will return the expected version number output.
Now you can execute npm commands.
I had the same problem.
I was using node 12 with nvm
Then, I switched to node 16, uninstalled the version 12 with nvm uninstall 12 and then I installed it again with nvm install 12 and it is working fine
For nvm used under macOS, I solve this issue in this way
First, run nvm ls-remote to get the latest version of v10
-> v10.24.1 (Latest LTS: Dubnium)
Then install the latest version of v10 through
nvm install 10.24.1 --latest-npm
In case anyone here needs to install an npm version (7.24.2) that does support node 10, rather than upgrade node.
Here is what I did:
url=`(curl -qSsL https://registry.npmjs.org/npm/7.24.2; echo "") | sed -e 's/^.*tarball":"//' | sed -e 's/".*$//'`
curl -qSsL -o npm.tgz "$url"
bin/npm-cli.js install -gf ../npm.tgz # in case npm is not installed where "which npm" points to, you might need to add --prefix=$(which npm | sed 's/\/bin\/npm//')
The reference is the installation script of 7.24.2 https://github.com/npm/cli/blob/v7.24.2/scripts/install.sh
In my case I had put ^ in one of the package version in my package.json. Which takes latest version of that library and it was not compatible to older npm version which caused me this error.
Remove all ^ from package versions and try again.
your nodejs version should come with its own npm that it supports.so if your machine has issues finding the npm version go to cdrive C:\Users\Machine name\AppData\Roaming
delete npm and npm cache folders.
Try below command
brew install node
then
npm install
None of the tips I found here helped.
I had to reinstall nvm.

Unexpected end of JSON input error when creating new project

Each time I use angular/cli to create a new project by launching the following command
ng new Project-Name
I get the following error
npm ERR! Unexpected end of JSON input while parsing near '...-4","#angular/common"'
I tried to force clean the cache and re-try but still face the same problem.
NodeJS version: 12.16.3
npm version: 6.14.4
Angular CLI version: 9.1.4
OS: Windows 10 Home win32 x64
Edit: All the commands above I run them in Powershell as administrator
This is not a definitive answer but it looks like your global packages are corrupted in some way.
This bug may be caused by many different things. I suggest doing the following.
Install Node Version Manager (or NVM for Windows) and install Node version 10.16.1. This is enough for angular 9 and from my experience it is the most stable version for development. This should also change your NPM version so that may also help.
Uninstall global angular package npm uninstall -g #angular/cli
Force clear cache npm cache clean --force
Just to double check npm cache verify
You can also try clearing your %temp% and %roaming% AppData/npm-cache
install latest angular package npm install -g #angular/cli#<your-version>
if this error still occurs, consider using another shell
If this don't solve the problem try to manually locate the package.json file that is throwing an error and investigate.

Npm isn't getting automatically installed on installing node.js

While hosting my webapp on heroku I got a message of some bugs in my npm package, my npm package was of version 3 and node.js was of version 8, I wrote thinking that I can update my npm version I tried to update it but the version remained same so I decided to uninstall it and wrote the command "npm uninstall " and than again tried to install npm but in vain ,finally I uninstalled my node.js and reinstalled tha npm will automatically get installed with it, but this too didn't work now I have node of version 10 with no npm which I got to know by checking version of npm which gave me message of "command not found ", now my every try to install npm has failed , may anyone suggest me what I can do to restore my losses and resume my work.
I am not sure if you have Linux or Windows. First I would check if the npm folder is in path.
You can follow one of these two to add to path if it is not done yet.
Windows
Linux
Alternatively you can install node with node version manager (nvm):
nvm linux and mac
nvm windows

Node js npm error code 1 while installing node inspector

Hello I'm kind of new to node js. I using node version 7.0.0 of CURRENT category.I was trying to install the node inspector using command prompt but ending up getting npm err code 1. I have tried to clean the npm cache but not working.
Any suggestion would be highly appreciated.
Try updating your 'npm'
npm install -g npm
I had the same issue running the above command and reinstalling the package fixed my issue.

Hiccup installing Node.js and NPM

I'm installing Node.js and NPM, so I used Homebrew to do so. I tried npm -v and node -v and they say:
-bash: npm: command not found
So I tried reinstalling, and I get this:
MacBook-Pro:5.0.0 User$ brew install node
Warning: node-5.0.0 already installed, it's just not linked
What can I do? Thanks!
You need to configure the environment variables,https://msdn.microsoft.com/en-us/library/bb726962.aspx

Resources