Run node js server in ubuntu
Solution 1
From our discussion here
After installing node.js
and npm
Create a symbolic link for node:
sudo ln -s /usr/bin/nodejs /usr/bin/node
Now verify commands working with
node -v
npm -v
Run it by using,
node hello.js
In order to test the application, open another terminal session and connect to your web server. Be sure to substitute in the app server's private IP address for APP_PRIVATE_IP_ADDRESS, and the port if you changed it:
curl http://APP_PRIVATE_IP_ADDRESS:8080
reference here
Solution 2
You just need to install one more package to get the links all working:
sudo apt-get install nodejs-legacy
This was explained and answered in detail already here.
Solution 3
The node
package that you installed when you ran sudo apt-get install node
is not actually NodeJS. Instead, the node
package actually predates NodeJS and installs Amateur Packet Radio.
The package you are looking for is actually nodejs
. However, installing nodejs
on Ubuntu will give you an outdated version of NodeJS. Alternatively, you can install NodeJS using a PPA or from Node Version Manager (nvm).
I've posted a comparison of the different installation methods with pros and cons. My personal preference when installing Node on an Ubuntu development machine is to install using NVM. If you're installing NodeJS on a production server, you'll be better off following instructions from Nodesource.
Related videos on Youtube
ujwal dhakal
MMA Fighter, Boxer, Part time doctor, teacher, stunner, seasonal model, heavy weight lifter, athlete well i am not any of them. PHP ,NODE ,GO developer ,Amature Blogger & Microservice Believer. Want to know how software development cycle looks like ? take a look Tips for making great softwares - "Break the code and grab some coffee " thats how you make it great.
Updated on September 18, 2022Comments
-
ujwal dhakal over 1 year
I have tried so far installed node.js and npm via
sudo apt-get install nodejs
andsudo apt-get install npm
. Then I tried typing node on bash nothing happens, I tried usingnode app.js
nothing happens to no error