I'm trying to use the 'forever' node.js package to run a node.js service on Ubuntu. Seems like it should be straightforward. However, when I run it, I receive the following output:
/usr/bin/env: node: No such file or directory
I think this may be because the Ubuntu package manager names the node.js binary nodejs, rather than node, which is more standard. Is there a way to tell the forever package where to find node?
(I did try symlinking /usr/bin/node to /usr/bin/nodejs, but that produced even more errors and it feels like a hack anyway)
Have you tried installing the latest node from source?
git clone https://github.com/joyent/node.git
cd node
git checkout v0.8.22 #Try checking nodejs.org for what the stable version is
./configure
make
sudo make install
This video isn't entirely clear, but the author implies that older versions of node in the Debian repository are behind the node/nodejs naming issue.
Alternatively, you could try finding the target of the /usr/bin/nodejs symlink using any of the methods described here and create a /usr/bin/node symlink to that.
Good luck!
Related
I'm trying to install LESS css in Netbeans, but I'm running into one problem after another. As such, I already have LESS installed, but I can't get it running.
Less is installed via the npm package, I installed it using the packaging system, less itself via Terminal. The first problem I had was that despite a successful installation, Netbeans didn't get to the files he needed (usr/local/), I could either change permissions there, which I don't want to dig into, or change the location. So I changed the location of the .npm and .npm-global folders to my root (home/ivet/), from where Netbeans managed to load it.
So I set everything there, the general settings and the specific project and it looked fine.
I want it to be converted to css automatically after saving, but it throws the message "/usr/bin/env:"node": Directory or file does not exist" and the target css file is still empty.
I found a few advices, basically the same: "ln -s /usr/bin/node/ usr/local/bin/nodejs", but it tells me that the link already exists and nothing will solve it. On closer inspection, I found that the link does exist, but the target file does not exist.
I've also found that installing Nodejs legacy solves this, but this is an older piece of advice, the package no longer exists, and terminal pretends to have the packages that replace this installed. Even when searching for via grep, I couldn't find the file it should link to (neither node nor nodejs).
There are the same tips everywhere that don't work for me and I don't know what to try next. I use Linux Mint 20, but I call myself a Linux BFU, so please write answer step by step :-D
Thanks for the advice
Try completely removing NodeJS & npm and try to install NodeJS using nvm i.e., node version manager.
You can follow this link on how to install nodejs and npm using nvm.
It's always a tedious task sometimes when it comes to package managment with npm, so it's better to go with nvm and I strongly suggest to always have a fallback option for node version when using with or without nvm i.e.,
NodeJS LTS version & NodeJS latest/stable version.
There's also an alternative solution i.e.,you can try switching to yarn package manager.
I've had this issue on Ubuntu and I've resolved it likes this:
First of all I've removed node and npm packages via
sudo aptitude remove node npm
Then I've added the official repositories
curl -fsSL https://deb.nodesource.com/setup_14.x | sudo -E bash -
After which I've just updated the list of packages with sudo aptitude update and then installed Node
sudo aptitude install nodejs npm
And that was it. With these steps done, everything just started to work.
I have a virtual machine running Bitnami and my current Nodejs version is v9.8.0 but i wanted to change my version to 8.11.1 and to do that i used n npm package but still the version of NodeJs is same.
I used below commands
sudo npm cache clean -f
sudo npm install -g n
sudo n 8.11.1
Can anyone please help me.
Bitnami Engineer here.
Bitnami Stacks are completely self-contained and run independently of the rest of the software or libraries installed on your system. This means that you don't have to worry about installing any other software on your system to make the new application work. They also won't interfere with any software already installed on your system, so everything you're already running will continue to work normally.
In this case, the PATH environment variable is configured to use the Bitnami binaries before the system's ones
PATH=/opt/bitnami/redis/bin:/opt/bitnami/python/bin:/opt/bitnami/nodejs/bin:/opt/bitnami/git/bin:/opt/bitnami/apache2/bin:/opt/bitnami/common/bin:/opt/bitnami/redis/bin:/opt/bitnami/python/bin:/opt/bitnami/nodejs/bin:/opt/bitnami/git/bin:/opt/bitnami/apache2/bin:/opt/bitnami/common/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
In case you try to find all the node binaries in the system
bitnami#bitnami-nodejs-dm-1072:~$ which -a node
/opt/bitnami/nodejs/bin/node
/opt/bitnami/nodejs/bin/node
/usr/local/bin/node
The first 2 "node" is the Bitnami's ones, the 3rd one is the system's one. If you use it, you will have the new Node.js version that you installed
bitnami#bitnami-nodejs-dm-1072:~$ /usr/local/bin/node --version
v8.11.1
Node noob here.
I had previously installed both npm and node separately.
Apparently, npm comes with node now. (link)
To my newbie mind, this means my previous dual installation is old and ugly. 1 binary > 2 binaries. So i uninstalled both.
Then I installed the latest node following the procedure. (i am running eOS)
Terminal
user#box:-$ which node
/usr/bin/node
user#box:-$ node -v
v0.10.22
user#box:-$ which npm
user#box:-$ npm -v
bash: /usr/bin/npm: No such file or directory
I can always run:
curl https://npmjs.org/install.sh | sh
but that seems to indicate that npm is actually NOT included in node.
When they say they are included do they just mean the code is in the same repo, but the binaries are still different?
Final question I have /usr/bin/node as well as /usr/bin/nodejs
can i delete one of these? im not sure when/where i picked up a second copy.
Yes, the nodejs package includes both node and npm executables. The code for each has its own repo, but when packaged both are included.
npm source: https://github.com/isaacs/npm
node source: https://github.com/joyent/node
When you install that .deb file from the PPA, you should get both /usr/bin/nodejs and /usr/bin/npm and 2 symlinks at /usr/bin/node (which points to) /etc/alternatives/node (which points to /usr/bin/nodejs).
If any of this isn't true, your install didn't fully succeed, most likely due to conflicting files you left around from your manual install. I would suggest uninstalling the .deb then making sure there are no stale files left from your manual install and then installing again.
Only node.js packages comes with npm. so if you are installing using an .msi, .exe, .dmg .pkg, .deb or using a package installer like apt-get, yum or brew, then you'll have both node and npm.
However,npm is not part of the node core. if you are installing node and using a method where you are using ./configure or make install || make link, then npm will not be installed, and will need to be compiled using the same type of installation, and node will have to be placed on your path.
If you used git, or unzipped node and you can see a configure script, then you will also need to acquire npm.
I've had issues (mostly on Mac) with npm ending up in directories that aren't in the terminal PATH. If you can figure out where npm is located, you can just add it to your path with something like:
export PATH=$PATH:/path/to/npm
I think (I'm not on a mac so I can't check at the moment) that it sometimes gets put in /usr/local/share/. But at any rate, the problem is likely NOT that npm isn't installed, but that it's installed somewhere you're not expecting.
Few months ago i had started learning the react so all this stuff i needed to install my laptop that had the ubuntu operating system.
What i did -- First i installed the node and without knowing that it came up with the npm package. I installed the npm package again.. but there was no conflict at all.
But after exploring all these things that nodejs have npm package. So i uninstalled the npm package due to concern about memory usage..
And Now everything is working fine....
Does anyone know if installing the latest build from source is a risky route to take? Should i just stick with the package manager?
Current recommendations
Use install-node-on-linux if you want a really simple install with your user account (disclaimer: I'm the author).
Use nvm if you want to install with your user account + you need to regularly switch between versions, and you're cool with a little bit of tool and environment complexity.
Follow the directions here to install via the NodeSource PPA. This is easy to do but it's the least flexible.
Old Answer
Note: At the time of this writing I'm using Ubuntu 12.10.
There are a lot of ways to install node. I personally prefer to download the source of the latest stable build and just install it to ~/local (you do this by adding --prefix to the ./configure command as seen here. There really isn't any 'risk' in doing this as everything gets installed in a directory which is separated from the rest of your system. You can have a look at the node recipe in my system install scripts here. I regularly run my update_node.py script to upgrade my installation to the latest version.
Alternatively you can follow the directions here to install the latest stable version via the package manager. I haven't actually done that so I can't comment on how well it works.
What I wouldn't do is install node from the ubuntu universe packages. You'll end up with a very dated version (currently 0.6.19).
update 1/26/2013:
If you are interested in installing node with your user (non-root) account, I highly recommend reading this blog post. I skipped the ~/.npmrc step, but found that the ~/.node_modules symlink step was critial for getting require to work properly.
update 12/30/2014:
I have migrated to using linux mint and doing binary node installs. If you have any interest in writing your own installation scripts, you can find my current one here. Specifically have a look at what I'm doing in node.sh. The execute function is run during the first install so it does things like configure the paths in .bashrc. The install function is run by update-node.sh and is used to remove an existing installation and add a new one (the latest version or one specified by the user).
update 1/8/2016:
I just switched over to using nvm. Simply install the script and then run nvm install node to get the latest version. This seems like an excellent way to get node installed with your user account.
another option is nvm (Node Version Manager) : https://github.com/creationix/nvm
bonus that it lets you easily switch between versions.
Although I live in an .rpm, and not .deb realm, fpm can do both (needs Ruby installed). I have been able to package node.js from the latest stable source without any major difficulties. In your case, the following scenario may help:
./configure --prefix=/usr
make
mkdir -p /tmp/nodejs
make install DESTDIR=/tmp/nodejs
fpm -s dir -t deb -n nodejs -v 0.8.15 -p nodejs-0.8.15.deb -C /tmp/nodejs usr
I'm trying to install socket.io on my machine, but I keep encountering errors when I run npm install socket.io as directed on their website. I'm not sure if I have version incompatibilities for npm or node.js or if I'm simply missing something obvious. As far as I can tell, I have the most recent stable version of both of them.
When I run the install command, the console outputs 40+ errors, and at the end I am given the line npm not ok. Any ideas as to what is going wrong?
What is the error?
Are you installing npm using code from git? I can only guess that you are not using a stable code, because the master branch from git is often unstable.
If that is the case, what you can do is to get the latest code from the git repository and install it again.
$ cd npm
$ git pull
$ make install
Hope it will solved your problem.
You need to provide an error log if you want anyone to try and troubleshoot your problem. It would also be helpful to know whether you installed Node and NPM from source or RPM. Furthermore, if you installed from source, did you do a standard install or did you make customisations?
If you are able to start from scratch, I suggest following the steps below and seeing how you go. Installing into your home directory won't require root and it makes it easier to clear everything out if you need to start again.
Install the stable release of Node in your home directory (use ./configure --prefix=~/Node/)
Set your path as appropriate (ie. PATH=/home/user/Node/bin:$PATH)
Run the standard NPM installer (curl http://npmjs.org/install.sh | sh)