Recently working with NodeJS ect. I installed quite different packages, for different tutorials + projects.
I finally ended up with this kind of configuration:
louis#louis:~$ node -v
v5.10.0
louis#louis:~$ nodejs -v
v6.2.1
louis#louis:~$ npm -v
3.8.3
Can you explain the difference between these?
Your situation
Seems you have two different versions of nodejs installed, possibly one was installed from sources and one from package manager like apt.
louis#louis:~$ node -v
v5.10.0
This returns older version of nodejs that you installed, I recommend you to remove it.
louis#louis:~$ nodejs -v
v6.2.1
This returns the current version of nodejs installed, possibly you installed it using package manager, I remember in Ubuntu it comes by nodejs executable name.
I suggest you to create link like this
sudo ln -s `which nodejs` /usr/bin/node
so it will be available using node command also.
nodejs vs node on ubuntu 12.04
louis#louis:~$ npm -v
3.8.3
This is just version of your npm program and has nothing to do with nodejs version.
Better solution
Uninstall all versions that you have and install node using nvm to switch between old/new versions easily
To install or update nvm, you can use the install script using cURL:
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.31.1/install.sh | bash
or Wget:
wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.31.1/install.sh | bash
Usage
To download, compile, and install the latest v5.0.x release of node,
do this:
nvm install 5.0
And then in any new shell just use the installed version:
nvm use 5.0
https://github.com/creationix/nvm#install-script
I assume you are using ubuntu. node and nodejs are the same tool, but node is the legacy version and nodejs the current development branch.
npm however is the package manager for node(js).
Here's a bit of helpful information to add to the discussion and which will hopefully help you out regarding node version clashes.
Adding the NodeJs version to your $PATH in your .bash_profile (or it may be called .bashrc or .bashconfig) file will ensure your node calls from the terminal will use the latest and not the legacy version.
Using NVM (Node Version Manager) will allow you to install and change node versions on the fly with 'nvm use 6.0.0' and is highly recommended as some NPM packages will break if using a node and npm version that isn't correct for certain npm packages in your node_modules dir.
You will also have to add NVM to your $PATH in this case, but it's easy enough to do with:
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm
More details can be found in the link provided.
The OP's question was answered, I know, but I think pointing the OP to a better solution is also a good idea.
Related
In the terminal, using nvm, I would like to run npm install <something> and have npm install the package in the node version that I'm currently using. Currently, no matter what version I have set using nvm, by default, nvm is installing all packages in node version 9.4.0.
I have ran the command nvm use v10.15.3 which switches me to that current version. When I run a command npm install -g ionic#latest (or any global command) it always installs it in the version 9.4.0 directory.
My output after running the command...
.../.nvm/versions/node/v9.4.0/bin/ionic -> .../.nvm/versions/node/v9.4.0/lib/node_modules/ionic/bin/ionic
This happens even though I'm currently on 10.15.3 (I would expect to install in the directory v10.15.3 and not v9.4.0
I'm using nvm version 0.34.0.
bash_profile
export NVM_DIR=~/.nvm
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"
source ~/.nvm/nvm.sh
You need to change the global version of node installed.
nvm install node --reinstall-packages-from=node
is useful for moving your tools to the new Node.js version.
See usage: https://github.com/creationix/nvm#usage
I think it's a path issue, can you add your bashrc, npmrc or profile to the question?
When I try to install node-sass using npm, I get the following error message:
Cannot download "https://github.com/sass/node-sass/releases/download/v3.13.1/win32-x64-57_binding.node":"
The command I use is:
npm install node-sass --save-dev-
You can see more details in the screenshot below:
After struggling , finally found exact solution.
In node js software folder, node-sass\4.5.0 folder is still created in npm-cache folder. So I download win32-x64-48_binding.node manually, put it in C:\Users\Administrator\AppData\Roaming\npm-cache\node-sass\4.5.0 folder.
And run npm install command, issue resolved.
I see you are running node version 8.1.4. You can also check it using node --version in the command prompt.
You'll have to use a version >= v4.5.3 instead because lower versions of node-sass are incompatible with node8. This issue has been reported on their GitHub issue page.
You either have to define using v4.5.3 instead or pass the the -g parameter while installing it, which seems to fetch the latest version automagically.
when i used -g it worked properly and got the latest version
Also, as #javiergarval has pointed out, you have a typo. It should have been --save-dev instead of --save-dev-.
My problem is, that I need an older node-sass Binary, which is not available for the new node version I have. But the solution is, at least on Windows, pretty simple. Just install the windows build tools. With that, npm is able to build the binaries out of the source.
Long story short, this solved the problem for me:
npm install --global --production windows-build-tools
Thanks to the answer on this question:
node-sass installation issue on windows 10
Depends on which node version you are using. Node-Sass currently supports only these versions:
Supported Node.js versions 0.10, 0.12, 1, 2, 3, 4, 5, 6 and 7.
If you happen to work on one of those versions, try to specify which version of node-sass you want:
$ npm install --save-dev node-sass#4.5.3
your npm is trying to download node-sass version 3.31.1 which is does not exist on the releases page of https://github.com/sass/node-sass/releases
You have an error on your command:
$ npm install node-sass --save-dev-
^^^
Should be
$ npm install node-sass --save-dev
(without the last - on dev)
Also, it is giving you a WARNING because it wants to be installed globally.
See the official node-sass documentation.
And also, could be interesting for you to know the differences between --save and --save-dev.
version mismatch with node could be the issue. To install the working node-sass version, you can use
npm uninstall node-sass
npm install node-sass#4.14.0
remember to choose your version number based on the following table, and the node version you have, which you can check by the command node --version
You can find full info here
While searching for the solution, have checked the release versions of node-sass and found that "https://github.com/sass/node-sass/releases" the node file it was looking is committed in the latest release and not in the older version. After downloading the required file "win32-x64-64_binding.node" manually from the released version and placing it under C:\Users\Administrator\AppData\Roaming\npm-cache\node-sass\4.7.2 or simply by using npm install node-sass#latest works for me.
None of the above solutions worked for me, this is what I did:
Installed C++ build tools for Visual Studio
Then:
npm uninstall --save-dev gulp-sass
Under the same circumstances I tried to install the node-sass package. I got the error that it required different version. The culprit turned out to be the fact that I was installing not under client folder but in the main one.
After that I installed the appropriate version for Node (for example 12 -> 4.12) based on the answer from Error: Node Sass version 5.0.0 is incompatible with ^4.0.0
I try the following :
Installing npm and nodejs through apt.
Installing the latest npm version, like :
npm npm#install -g
Ending up with nodejs version 0.10 or something, and npm version 3.10.8
I try to install n throught npm, like (seems to be the answer on most forums) :
sudo npm cache clean -f
sudo npm install -g n
Then, I try to install the crap :
sudo n stable
Get an error :
cp: cannot stat '/usr/local/n/versions/node//bin': No such file or directory
etc
etc
Any ideas ? All I want is to get the latest version of nodejs.
I have tried to download the node tar, but how can I get nodejs to become the same version as node ?
There is a good manager that will help you with all node versions.
It's called nvm(Node version manager).
https://github.com/creationix/nvm
All install guides are on git page. I install it like this.
curl -sL https://raw.githubusercontent.com/creationix/nvm/v0.31.0/install.sh -o install_nvm.sh
bash install_nvm.sh
Check to see if everything installed correctly
nvm --version
Then when you want update node you can just do
nvm install 6.9.1 (or any version you like)
nvm alias default 6.9.1
nvm use default
After restarting of your terminal run
node -v you should have 6.9.1 installed and used.
Hope this helps.
I have Nodejs installed in my Mac, but I did it the regular way. One of the requirements in my new job, is to install node with something named NVM, so, what is the recommended way to uninstall Node, and re-install it with the NVM stuff?
To install it on a VPS:
curl https://raw.githubusercontent.com/creationix/nvm/v0.11.1/install.sh | bash
Read more here
As I run this piece of code using node a.js:
var sys = require('sys');
sys.puts('Hello, World');
I'm getting the following as an error
axconfig: port 1 not active
axconfig: port 2 not active
Warning: This is old but it might still work.
You didn't install node.js but the package node (that contains some other unrelated software) for your linux distro.
You can install node.js three ways: Using git, downloading the version file, or installing through the package manager, I recommend using the package manager for ease-of-use and the ability to easily update.
Package Manager
Check out Installing Node.js via Package Manager. It has instructions on how to install using the package manager of your preference.
Direct Download
Go the the downloads page of node.js and download the package for your OS. Don't forget that, doing i this way, doesn't auto-update node.js later on!
Source Compilation / git
First you need git and a compiler, here is how you install them on debian/ubuntu (this depends on your package manager):
sudo apt-get install git-core build-essential
(If you don't want to use git, you can download the source code from the website. You still need build-essential or equivalent for your OS.)
Then go to a folder where the "node" repository will be placed, something like ~/projects or ~/src is good enough, and do this:
git clone https://github.com/joyent/node.git
Then enter the node directory, configure it and build it.
cd node && ./configure && make
Everything should go well. Before installing node you can optionally run the tests to check for any problems:
make test
You can finally install node, this allows you to run the node command anywhere in the system and the javascript libraries to be installed.
make install
...and we are done.
You can test those lines of code using node-repl (node's REPL, think "interactive interpreter"), just type node-repl, quit with Ctrl+D.
axconfig: port 1 not active
axconfig: port 2 not active
this problem no where related to nodejs.
Do not install node using the command sudo apt-get install node, This will install radio package(node). this radio package requires axports to be active, which is not linked with nodejs
So uninstall node from sudo apt-get remove node
Manually Download nodejs from Here or from GitHub but make sure you install the stable branch(0.4.x).Unpack the nodejs.
For installing please follow the README.md
After installing then set the environment variables echo PATH=$PATH:/home/user/pathtonode/
you installed node, you want the package called nodejs
If you are on ubuntu, follow:
sudo apt-get update
sudo apt-get install python-software-properties
sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install nodejs
You need to install nodejs and not node!
Brandon Helwig is correct. It just happened to me. In general, if you get this type of error, you have installed the wrong package. Here are more instructions for you to install one of the latest versions of Node.js.
Fix
sudo apt-get remove node
This will remove the accidentally installed package. Both names for the package node and nodejs are the same which is node.
If you do sudo apt-get install node, what you would get is a old version. But thanks for Chris Lea, we got a PPA for this task.
sudo apt-get update
sudo apt-get install python-software-properties
sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install nodejs
This should get you the latest version of Node.js in your application.
If you are in need of an bleeding edge version, you can install from the source. But I think this is way cleaner.
This problem is occur in ubuntu,so I resolved this problem by git. Clone this new source from github
and do following actions:
Uninstall node
sudo apt-get remove --pure node
sudo apt-get clean
Make install node
git clone https://github.com/joyent/node.git
cd node
./configure
make
make install
Then this will be work well.
If Node.js installation as suggested by ninja works for you (like on AWS Ubuntu):
sudo apt-get update
sudo apt-get install python-software-properties
sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install nodejs
you might still want to add node to your system path like this:
export PATH=/usr/bin/:$PATH
so you can type
node webapp.js
instead of
/usr/bin/node webapp.js
Find your node installation path simply by typing
which node
The easiest way is to remove the node installation first and then install npm.
npm is the Node Package Manager, this will automatically install nodejs itself