gpt4 book ai didi

node.js - 在 Ubuntu 中安装没有 sudo 的 NodeJS

转载 作者:搜寻专家 更新时间:2023-10-31 22:29:46 30 4
gpt4 key购买 nike

我已经关注了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

我用谷歌搜索并尝试了来自 this SO answer 的以下内容

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

关于node.js - 在 Ubuntu 中安装没有 sudo 的 NodeJS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31025159/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com