Tôi đã theo dõi node-and-npm-in-30-seconds.sh.Cài đặt NodeJS mà không cần sudo trong Ubuntu
Trước đó, tôi đã sử dụng ứng dụng AngularJS sử dụng Yeoman và bower với NodeJS. Lúc đó tôi đã sử dụng sudo để cài đặt tất cả.
Đây là những gì tôi theo
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
Gần đây tôi đã cố gắng để tạo ra một ứng dụng AngularJS, nhưng nó không tạo đúng cách. Sau đó, tôi thấy tôi không nên sử dụng sudo trong khi cài đặt nodejs, yeoman và Bower.
Tôi đã tìm kiếm và tìm thấy giải pháp ở đây node-and-npm-in-30-seconds.sh.
Vì vậy, đầu tiên tôi gỡ cài đặt NodeJS
sudo apt-get remove nodejs
Sau đó, theo các tùy chọn đầu tiên được cung cấp trong liên kết
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
Lệnh cuối cùng đã không làm việc. Nó cho thấy
$ 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
Tôi googled và cố sau đây từ this SO answer
curl -O -L https://npmjs.org/install.sh
sh install.sh
nó đang hiển thị các lỗi sau
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
Tại sao nó như vậy? Và làm thế nào tôi có thể giải quyết nó? Cảm ơn.