I was using node versions 10.x.x and 12.x.x using nvm before.
Then i installed new node version using the command
npm install -g node#14.
and also installed new npm version using the command
npm install npm#6
after doing these if i do nvm use v10
its still not switching to node version 10
nvm list // apply this first
you will see differents options
v10.24.1
v12.13.0
v12.22.6
-> v14.13.1
...
then apply the command to use
nvm use v10.24.1
in your case:
nvm use v10.22.0
you need to copy paste completly like, not just v10
Related
I want to use an earlier version of node v14.7.0 and its respective npm. When I do that I still get the latest version of npm and not the earlier version.
How to get the earlier version?
You can rollback to the old version of npm using the following command
npm install -g npm#<version number>
for example:
npm install -g npm#3.1.1
if you want the latest version you can use:
#latest
instead of version number.
When I do that I still get the latest version of npm and not the
earlier version.
It could be due to not deleting it properly or you might be installing the latest version again.
I recommend you to use nvm if you are using a linux-based OS and nvm-windows for windows based systems. It will help you to keep different versions of node and npm and you can switch later based on the project requirements.
It is easy to install and use. Linux command:
nvm install node
For windows, you can install nvm-windows here.
nvm list
Once you do it, you can install different version of node and it will automatically give its associated npm version:
nvm install `versionnumber`
It is recommended to use Node Version Manager(NVM) to simplify changing versions. Then you can use like below from terminal or command line:
// Check installed versions:
nvm list
// Change version to 15:
nvm use 15
// Check node version:
node -v
// Switch version:
nvm use 16
// Install different version:
nvm install 11
I have a strange behaviour with nvm on macOS. Currently I have installed node version 12.18.0 together with npm version 6.14.4.
Today I wanted to update my npm so I just ran npm install -g npm. When I submitted the command nvm installed node version 12.20.1 together with npm 7.16.0.
So now I have the combinations of node 12.18.0 with npm 6 and 12.21.1 with npm 7.
I wouldn't mind that case but there are two problems which occur now:
When I set the new node version as default and restart the terminal it doesn't change. It stays at the system version (which is 10).
When I manually change the node version with nvm use default I get this warning: (node:55181) ExperimentalWarning: The fs.promises API is experimental
Isn't it possible to install the combination of node 12.18.0 and npm 7? And which node/npm version doesn't print out the warning?
Thanks in advance,
Matthias
Okay, I found the error. I had a .npmrc file in my home directory and in this the version 12.20.1 was set. When I deleted the file I could get the combination of node 12.18.0 and npm 7.
I've been using node 9.3.0 for a long time, but I recently migrated to 10.12.0. Everything went fine, when I do node -v and npm -v I get the correct versions:
Paul-Bergs-Macbook:node paulrberg$ node -v
v10.12.0
Paul-Bergs-Macbook:node paulrberg$ which node
/Users/paulrberg/.nvm/versions/node/v10.12.0/bin/node
Paul-Bergs-Macbook:node paulrberg$ npm -v
6.4.1
Paul-Bergs-Macbook:node paulrberg$ which npm
/Users/paulrberg/.nvm/versions/node/v10.12.0/bin/npm
Howeven, when I'm trying to run any npm command, the old version is used. That is:
Paul-Bergs-Macbook:node paulrberg$ npm i truffle -g
/Users/paulrberg/.nvm/versions/node/v9.3.0/bin/truffle -> /Users/paulrberg/.nvm/versions/node/v9.3.0/lib/node_modules/truffle/build/cli.bundled.js
+ truffle#4.1.14
added 81 packages from 311 contributors in 1.715s
And:
npm list -g --depth=0
/Users/paulrberg/.nvm/versions/node/v9.3.0/lib
└── truffle#4.1.14
Not sure if this is some bash code still pointing to the last version, but I can't seem to find any proof for that. Running env and checking for 9.3.0 environment variables yields no result.
What I did so far:
Delete node 9.3.0 with nvm uninstall 9.3.0
Do a fresh install of nvm after deleting it and rebooting the computer
nvm reinstall-with-packages
Deleted ~/.nvmrc and set 10.12.0 in there afterwards
Check if I have an overlapping node from homebrew and I don't
What could the problem be?
After a few hours of painful Unix debugging, I realised the problem was that I set a prefix in npm config:
prefix = "/Users/paulrberg/.nvm/versions/node/v9.3.0"
To fix this, make sure to unset the prefix by doing:
npm config rm prefix
This is mentioned, albeit not necessarily shining in the nvm doc
If you have an ~/.npmrc file, make sure it does not contain any prefix
settings (which is not compatible with nvm)
It looks like you might need to run nvm reinstall-packages
https://github.com/creationix/nvm#migrating-global-packages-while-installing
which says
Migrating global packages while installing
If you want to install a new version of Node.js and migrate npm packages from a previous version:
nvm install node --reinstall-packages-from=node
This will first use "nvm version node" to identify the current version you're migrating packages from. Then it resolves the new version to install from the remote server and installs it. Lastly, it runs "nvm reinstall-packages" to reinstall the npm packages from your prior version of Node to the new one.
You can also install and migrate npm packages from specific versions of Node like this:
nvm install 6 --reinstall-packages-from=5
nvm install v4.2 --reinstall-packages-from=iojs
The other "solution" is not to use global packages. Particularly when using nvm and not being able to be sure that the global package is for the "current" version it can be better to install locally and use npx to run the local command
truffle installs a truffle command to ./node_modules/.bin when you npm install it so you can npx truffle to run the local one instead of truffle to run the global one
edit:
another thing to check is that node -v and nvm current don't necessarily report the same version.
I wonder if nvm current would report v9.3 for you?
ah, yep, on my machine I can install truffle globally in a different location than node -v reports
> node -v
v9.5.0
> nvm current
system
> nvm use v8
Now using node v8.4.0 (npm v5.3.0)
> node -v
v8.4.0
> nvm current
v8.4.0
> npm install -g truffle
/Users/pauldambra/.nvm/versions/node/v8.4.0/bin/truffle -> /Users/pauldambra/.nvm/versions/node/v8.4.0/lib/node_modules/truffle/build/cli.bundled.js
+ truffle#4.1.14
added 81 packages in 4.364s
So you might be missing an nvm use v10 command
I think that a more permanent solution is this section from the support docs.
Default global packages from file while installing
If you have a list of default packages you want installed every time you install a new version, we support that too -- just add the package names, one per line, to the file $NVM_DIR/default-packages. You can add anything npm would accept as a package argument on the command line.
I install the nodejs its work wihtout any problem but when I try to install some packge with the npm.
The npm not work and give me this problem:
error: Cannot find module 'C:\Program Files\nodejs\node_modules\npm\bin\node_modules\npm\bin\npm-cli.js'
This the varaible system path:
The floder C:\Users\xxxxx\AppData\Roaming\npm is empty.
I dont now what is the problem why not work?
npm usually comes shipped with Node. Setup issues are very common while working with Node. I think it will be faster for You to do a clean reinstall than try to fix Your issue.
What I found working the best for me is using nvm. It's a command line tool which lets You install any version of Node and switch to any other version at any time.
You are on Windows 7, so what You are interested in is nvm-setup.zip from this source:
https://github.com/coreybutler/nvm-windows/releases
Run the setup and if it asks You about controlling versions press yes.
Now, run Your cmd.
Administrator#MECH-PC D:\a
$ nvm list
* 6.8.1 (Currently using 64-bit executable)
5.0.0
4.0.0
0.10.38
Administrator#MECH-PC D:\a
$ node -v
v6.8.1
Administrator#MECH-PC D:\a
$ npm -v
3.10.8
Administrator#MECH-PC D:\a
$ nvm install 5
5.0.0
Downloading node.js version 5.0.0 (64-bit)... Complete
Creating C:\Users\Administrator\AppData\Roaming\nvm\temp
Downloading npm version 3.3.6... Complete
Installing npm v3.3.6...
Installation complete. If you want to use this version, type
nvm use 5.0.0
Administrator#MECH-PC D:\a
$ nvm use 5
5.0.0
Now using node v5.0.0 (64-bit)
Administrator#MECH-PC D:\a
$ nvm list
6.8.1
* 5.0.0 (Currently using 64-bit executable)
4.0.0
0.10.38
Administrator#MECH-PC D:\a
$ node -v
v5.0.0
Administrator#MECH-PC D:\a
$ npm -v
3.3.6
Note
On Windows nvm use will persist selected version. In unix You need nvm alias default [VERSION] e.g. nvm alias default 6.8.1
Additional reading for unix guys:
http://www.nearform.com/nodecrunch/nodejs-sudo-free/
#Kamil Mech
I install tje nvm dna work but howa can I in integrate with nodejs ???
oooh I dont now where is the porblem but the npm now work
My questions are
Whenever i tried to install nodejs using command line
# apt-get install nodejs
it installs the older version (in my case it installed 0.10.x),where as the current version till date is 4.1.2 .Why this command do not gives me a latest version.Is there any other way to install the latest version though i tried using nvm.
I checked the installed versions
node -v && npm -v && cordova -v
v0.12.7
3.3.5
5.3.3
It seems node v0.12.7 is installed in my system but when i am trying to install ionic
npm install -g cordova ionic
i am finding the error
npm WARN engine xmlbuilder#2.2.1: wanted: {"node":"0.8.x || 0.10.x"}
(current: {"node":"0.12.7","npm":"3.3.5"})
even my current version is greater then the required version why its throwing me an error,do it strict with the specific version.
Do not make use of apt get, there is no harm in installing node using platform specific tools but it is better to make use of nvm which is consistent among all platforms.
Make sure to uninstall the current version of node this post can help.
Next follow these steps.
Go to https://github.com/creationix/nvm
Use curl to install nvm curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.28.0/install.sh | bash
Source your profile source ~/.profile
Install NodeJs nvm install v4.1.0
Alias installed version to default nvm alias default v4.1.0
Set aliased version as the final node version nvm use default
node -v will result in v4.1.0
In your case you may have to install version 0.10.x, you can also do nvm ls-remote to list available versions for download.
it's warning not an error so don't worry and if you want to install ionic platform then use bellow commands and still you face any problem then message me.
npm install -g ionic