簡體   English   中英

在Ubuntu中安裝沒有sudo的NodeJS

[英]Installing NodeJS without sudo in Ubuntu

我已經關注了node-and-npm-in-30-seconds.sh

之前我曾經使用Yeoman和bower與NodeJS創建AngularJS應用程序。 那次我用sudo來安裝所有。

這就是我所遵循的

sudo apt-get install python-software-properties python g++ make
sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install nodejs

sudo apt-get install git-core

最近我嘗試創建一個AngularJS應用程序,但它沒有正確創建。 然后我發現在安裝nodejs,yeoman和Bower時我不應該使用sudo。

我在這里搜索並找到了解決方案node-and-npm-in-30-seconds.sh

所以首先我卸載了NodeJS

sudo apt-get remove nodejs

然后按照鏈接中提供的第一個選項進行操作

echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
mkdir ~/local
mkdir ~/node-latest-install
cd ~/node-latest-install
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1
./configure --prefix=~/local
make install # ok, fine, this step probably takes more than 30 seconds...
curl https://www.npmjs.org/install.sh | sh

最后一個命令不起作用。 這顯示了

$ curl https://www.npmjs.org/install.sh | sh
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100    51  100    51    0     0     63      0 --:--:-- --:--:-- --:--:--    63
sh: 1: Moved: not found

我用谷歌搜索並嘗試了以下SO答案

curl -O -L https://npmjs.org/install.sh
sh install.sh

它顯示以下錯誤

npm cannot be installed without node.js.
Install node first, and then try again.

Maybe node is installed, but not in the PATH?
Note that running as sudo can change envs.

PATH=/home/myuser/local/bin:/usr/lib/jvm/java-7-oracle/bin:/usr/lib/jvm/java-7-oracle/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games

為什么會這樣? 我該如何解決? 謝謝。

好的,我已經嘗試過並為我工作過

echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
mkdir ~/local
mkdir ~/node-latest-install
cd ~/node-latest-install
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1
./configure --prefix=$HOME/local
make install
curl -L https://www.npmjs.com/install.sh | sh

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM