Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
264 views
in Technique[技术] by (71.8m points)

node.js - I downloaded NodeJS from the official website but it doesn't work Ubuntu

On the official NodeJS website I downloaded the recommended windows installer. I tried on Ubuntu to see my version, node -v, and it doesn't work. When I type anything with node it says:

command 'node' not found, but can be installed with:
sudo apt install nodejs

I tried sudo apt install nodejs and I got another error:

Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package nodejs

Trying npm is not any better

: not foundram Files/nodejs/npm: 3:
: not foundram Files/nodejs/npm: 5:
/mnt/c/Program Files/nodejs/npm: 6: Syntax error: word unexpected (expecting "in")

However, when I search node on the windows task bar, there is a node app that is listed and it opens a terminal. I'm new to Linux and it's my first time using Ubuntu, and I'm on windows 10, please advise me on what to do. Thanks.

question from:https://stackoverflow.com/questions/65865421/i-downloaded-nodejs-from-the-official-website-but-it-doesnt-work-ubuntu

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Try, 'sudo apt update', then 'sudo apt install nodejs' -- no space between node and js

If that doesn't work:

Using Ubuntu

curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash - sudo apt-get install -y nodejs

Try this

sudo apt install curl
curl https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash

then

nvm install stable


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...