node.js - Not able to run my node app at port 80 on ubuntu 16.04


Question: 

I want to run my node app at port 80 in ubuntu 16.04. But the moment I'm trying to run my app with npm start its throwing error Port in already in use whereas it's not in use. According to Github Reply, We need root privileges to run on ports below 1048 which is correct. So the moment I'm trying to run my app like this sudo npm install it's throwing sudo: npm: command not found

So can anyone suggest me, how to run npm start with root privileges on ubuntu. I did googling but couldn't find anything.




2 Answers: 

First run which npm to get the full path to npm.

Then run sudo FULL_PATH_TO_NPM start.

Or to make a one-liner:

sudo $(which npm) start
 

Both sudo and npm(including node) should be same directory. For example sudo is always available in /usr/bin/ so after installing npm and node should also go in /usr/bin/. earlier I was using NVM to install node and npm. I removed .nvm directory and referred node installation link which placed both npm and node in /usr/bin/. And then now I'm able to run npm with sudo.

 

More Articles


shell - Change the Particualy string value without string comparison in a file using Command line Ubuntu

I want to create a shell script to change the string values which is after '=' in my file Using command line.File is like: String name = "Max"; String age = "24"; String address = "Noida";OrString name=MaxString age=24String address=NoidaBut here, I don't wanna string comparison, Like this:$ sed -i

bash - How does the keyword “if” test if a value is true or false?

In bash scriptif [ 1 ]then echo "Yes"else echo "No"fiOutput: YesIt represents that '1' is treated as true value.But in code:word = Linuxletter = nuxiif echo "$word" | grep -q "$letter"then echo "Yes"else echo "No"fiOutput: NoBut echo "$word" | grep -q "$letter" will return 1, so why is the

linux - diff command to get number of different lines only

Can I use the diff command to find out if two of files differ by k lines?I don't want the contextual difference, just the total number of lines that are different between two files. Best if the result is just a single integer.


bash - append text to file using shell from php

I trying to append passed text as parameter to file using shell scriptthis is the code of shell echo $1>>/etc/freeradius/mods-enabled/ldapthis shell will get the text to add it to the file ldap in /etc/freeradius/mods-enabled path , I call this shell in this format # sh /etc/append.sh hello

ubuntu - Shell command to get remote system's ip address from its mac address?

I have the HWAddress of remote machine but its IP address is not static and keeps changing. How do I get its IP address through shell?Relevant questions mostly have the remote system in the same network, but in my case its not.EDIT: I know its IP range.

ruby on rails - tmux: are my other terminals still running?

I have started using a certain technique for launching my web code since I switched server setups. I type tmuxsudo startserverrailsCtrl+B then DThen to reboot I type tmuxsudo killall rubysudo startserverrailsCtrl+B then DMy questions are: when I kill the ruby, does that end the session that I starte


php - How to redirect everything after slash to domain before?

This is what I'm trying to do:I want example.com/car/{whatever} redirected to example.com/{whatever}. For example, example.com/car/honda should be redirected to example.com/hondaBUT if there is nothing after /car/, then just leave it as that. How can i do that in .htaccess ?

node.js - Querying multiple sensors regularly using NodeJS

I need to fetch the values of about 200 sensors every 15 seconds or so. To fetch the values I simply need to make an HTTP call with basic authentication and parse the response. The catch is that these sensors might be on slow connection so I need to wait at least 5 seconds for one sensor (but usuall

Shell script - convert Excel (xlsx) to CSV - remove blank space / tab space

I receive excel file (xslx) with multiple sheets for my project. The number of records on these sheets ranges from 15k to 70k per sheet. I need to perform following tasks on this data and then convert it to CSV. Or covert to CSV and then process the data either way its fine.Input Example:call_no un

mysql - Apache2 / phpmyadmin - PHP isn't working

I was working on a project of mine . then i had to restart the computer.Once I did suddenly PHP stopped working on Apache. then i starting looking into the configuration files and error logs and fixed a spelling error in the config file, but STILL the problem persisted, then i decided to re-install