简体   繁体   English

无法在Ubuntu 16.04的端口80运行我的节点应用程序

[英]Not able to run my node app at port 80 on ubuntu 16.04

I want to run my node app at port 80 in ubuntu 16.04. 我想在ubuntu 16.04的80端口运行我的节点应用程序。 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. 但是,当我尝试使用npm start运行我的应用npm start它的抛出错误Port已在使用中 ,而未在使用中。 According to Github Reply , We need root privileges to run on ports below 1048 which is correct. 根据Github回复 ,我们需要root特权才能在1048以下的端口上运行,这是正确的。 So the moment I'm trying to run my app like this sudo npm install it's throwing sudo: npm: command not found 因此,当我尝试像sudo npm install这样运行我的应用sudo npm install它会抛出sudo:npm:命令未找到

So can anyone suggest me, how to run npm start with root privileges on ubuntu. 所以有人可以建议我,如何在ubuntu上以root特权运行npm start I did googling but couldn't find anything. 我做了谷歌搜索,但找不到任何东西。

First run which npm to get the full path to npm. 首先运行which npm以获得which npm的完整路径。

Then run sudo FULL_PATH_TO_NPM start . 然后运行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. sudo和npm(包括节点)应位于同一目录。 For example sudo is always available in /usr/bin/ so after installing npm and node should also go in /usr/bin/ . 例如,sudo始终在/usr/bin/可用,因此在安装npm后,node也应该在/usr/bin/ earlier I was using NVM to install node and npm. 之前,我使用NVM安装node和npm。 I removed .nvm directory and referred node installation link which placed both npm and node in /usr/bin/ . 我删除了.nvm目录,并引用了节点安装链接 ,该链接将npm和node都放置在/usr/bin/ And then now I'm able to run npm with sudo. 然后,我现在可以使用sudo运行npm了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM