简体   繁体   English

NodeJ无法正确安装-Ubuntu 16.06

[英]NodeJs not installing properly - ubuntu 16.06

I have followed This digital ocean tutorial for installing node . 我已经按照此数字海洋教程安装节点。 and when i tried to run command sudo apt-get install npm it gave me error that 当我尝试运行命令sudo apt-get install npm时,出现了以下错误

The following packages have unmet dependencies: npm : Depends: node-gyp (>= 0.10.9) but it is not going to be installed E: Unable to correct problems, you have held broken packages. 以下软件包具有未满足的依赖关系:npm:依赖:node-gyp(> = 0.10.9),但不会被安装E:无法纠正问题,您拿着损坏的软件包。

I removed it completely using This Post and install nodeJs again using This NVM tutorial It ended successfully installing .I made app.js with "hello world" as response and run the command node app.js and when i hit the localhost:3000 it showed Hello world - But once i closed my terminal and run node app.js it failed saying The program 'node' is currently not installed. 我使用此帖子将其完全删除,并使用此NVM教程再次安装了nodeJs。安装成功结束。我使用“ hello world”作为响应制作了app.js并运行了命令节点app.js,当我点击localhost:3000时,它显示世界,您好-但是,一旦我关闭终端并运行节点app.js,它就会失败,提示当前未安装程序“节点”。 You can install it by typing: sudo apt install nodejs-legacy while i have done that before . 您可以通过键入以下命令进行安装:sudo apt install nodejs-legacy而我之前已经这样做了。 It only runs again if i follow all the steps of nvm installation again 仅当我再次执行nvm安装的所有步骤时,它才能再次运行

please try below command to install nodejs. 请尝试以下命令来安装nodejs。

sudo apt-get install -y nodejs
    sudo apt-get install npm
    sudo npm install n -g
     version is:`-- n@2.1.4 



*following commands are used to run nodejs program
node
>console.log("Hello World!");
above command print hello world in cmd

ctrl+d is used to terminate from cmd

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

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