在 ubuntu 中安装 node-威尼斯人最新

thingskit · 2021年06月07日 · 最后由 回复于 2022年08月20日 · 869 次阅读
本帖已被设为精华帖!

安装 node-red

在 ubuntu 中依次输入:

sudo apt-get remove nodejs
sudo apt-get update
sudo apt-get install nodejs
sudo apt-get install npm
sudo npm install -g node-red
node-red

就是说 npm 出于安全考虑不支持以 root 用户运行,即使你用 root 用户身份运行了,npm 会自动转成一个叫 nobody 的用户来运行,而这个用户几乎没有任何权限。这样的话如果你脚本里有一些需要权限的操作,比如写文件(尤其是写 /root/.node-gyp),就会崩掉了。

为了避免这种情况,要么按照 npm 的规矩来,专门建一个用于运行 npm 的高权限用户;要么加 --unsafe-perm 参数,这样就不会切换到 nobody 上,运行时是哪个用户就是哪个用户,即是 root。

npm install --unsafe-perm

登录

在谷歌浏览器中输入

安装 git

npm config set registry https://registry.npm.taobao.org    #使用淘宝镜像
npm config get registry                                
sudo apt-get update
sudo apt-get install git
git --version
sudo apt install python2.7

设置软连接

ln -s /home/nodejs/bin/npm   /usr/local/bin/npm
ln -s /home/nodejs/bin/node  /usr/local/bin/node

安装 npm 报错:

err:16 http://ports.ubuntu.com/ubuntu-ports xenial/main armhf libalgorithm-diff-perl all 1.19.03-1
  unable to connect to ports.ubuntu.com:http: [ip: 2001:67c:1562::18 80]
err:17 http://ports.ubuntu.com/ubuntu-ports xenial/main armhf libalgorithm-diff-xs-perl armhf 0.04-4build1
  unable to connect to ports.ubuntu.com:http: [ip: 2001:67c:1562::18 80]
err:18 http://ports.ubuntu.com/ubuntu-ports xenial/main armhf libalgorithm-merge-perl all 0.08-3
  unable to connect to ports.ubuntu.com:http: [ip: 2001:67c:1562::18 80]
err:19 http://ports.ubuntu.com/ubuntu-ports xenial/main armhf libfile-fcntllock-perl armhf 0.22-3
  unable to connect to ports.ubuntu.com:http: [ip: 2001:67c:1562::18 80]
err:20 http://ports.ubuntu.com/ubuntu-ports xenial/main armhf libjs-jquery all 1.11.3dfsg-4
  unable to connect to ports.ubuntu.com:http: [ip: 2001:67c:1562::18 80]

澳门人威尼斯3966的解决方案:

export http_proxy=http://us.archive.ubuntu.com:80

执行 sudo npm install -g node-red 报错

npm err! linux 4.1.15
npm err! argv "/usr/bin/nodejs" "/usr/bin/npm" "install" "-g" "node-red"
npm err! node v4.2.6
npm err! npm  v3.5.2
npm err! code econnreset
npm err! errno econnreset
npm err! syscall read
npm err! network read econnreset
npm err! network this is most likely not a problem with npm itself
npm err! network and is related to network connectivity.
npm err! network in most cases you are behind a proxy or have bad network settings.
npm err! network 
npm err! network if you are behind a proxy, please make sure that the
npm err! network 'proxy' config is set properly.  see: 'npm help config'
npm err! linux 4.1.15
npm err! argv "/usr/bin/nodejs" "/usr/bin/npm" "install" "-g" "node-red"
npm err! node v4.2.6
npm err! npm  v3.5.2
npm err! code econnreset
npm err! errno econnreset
npm err! syscall read
npm err! network read econnreset
npm err! network this is most likely not a problem with npm itself
npm err! network and is related to network connectivity.
npm err! network in most cases you are behind a proxy or have bad network settings.
npm err! network 
npm err! network if you are behind a proxy, please make sure that the
npm err! network 'proxy' config is set properly.  see: 'npm help config'

澳门人威尼斯3966的解决方案

使用 proxy 来代理访问:

npm config set registry https://registry.npm.taobao.org 

执行 sudo npm install -g node-red 报错 ii

npm err! linux 4.1.15
npm err! argv "/usr/bin/nodejs" "/usr/bin/npm" "install" "-g" "node-red"
npm err! node v4.2.6
npm err! npm  v3.5.2
npm err! cannot read property 'emit' of null
npm err! 
npm err! if you need help, you may report this error at:
npm err!     <https://github.com/npm/npm/issues>
npm err! linux 4.1.15
npm err! argv "/usr/bin/nodejs" "/usr/bin/npm" "install" "-g" "node-red"
npm err! node v4.2.6
npm err! npm  v3.5.2
npm err! cannot read property 'emit' of null
npm err! 

gyp err! stack error: not found: make


node-pre-gyp warn using request for node-pre-gyp https download
node-pre-gyp warn tried to download(404): https://github.com/kelektiv/node.bcrypt.js/releases/download/v3.0.8/bcrypt_lib-v3.0.8-node-v64-linux-arm-glibc.tar.gz
node-pre-gyp warn pre-built binaries not found for bcrypt@3.0.8 and node@10.4.0 (node-v64 abi, glibc) (falling back to source compile with node-gyp)
gyp err! build error
gyp err! stack error: not found: make
gyp err! stack     at getnotfounderror (/home/nodejs/lib/node_modules/npm/node_modules/which/which.js:13:12)
gyp err! stack     at f (/home/nodejs/lib/node_modules/npm/node_modules/which/which.js:68:19)
gyp err! stack     at e (/home/nodejs/lib/node_modules/npm/node_modules/which/which.js:80:29)
gyp err! stack     at /home/nodejs/lib/node_modules/npm/node_modules/which/which.js:89:16
gyp err! stack     at /home/nodejs/lib/node_modules/npm/node_modules/isexe/index.js:42:5
gyp err! stack     at /home/nodejs/lib/node_modules/npm/node_modules/isexe/mode.js:8:5
gyp err! stack     at fsreqwrap.oncomplete (fs.js:184:21)
gyp err! system linux 4.1.15
gyp err! command "/home/nodejs/bin/node" "/home/nodejs/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "build" "--fallback-to-build" "--module=/home/node-red-1.3.5/node_modules/bcrypt/lib/binding/bcrypt_lib.node" "--module_name=bcrypt_lib" "--module_path=/home/node-red-1.3.5/node_modules/bcrypt/lib/binding" "--napi_version=3" "--node_abi_napi=napi" "--napi_build_version=0" "--node_napi_label=node-v64"
gyp err! cwd /home/node-red-1.3.5/node_modules/bcrypt
gyp err! node -v v10.4.0
gyp err! node-gyp -v v3.6.2
gyp err! not ok

澳门人威尼斯3966的解决方案:

npm install -g npm
sudo apt-get install make
sudo apt install build-essential
thingskit 将本帖设为了精华贴 06月07日 20:03
需要 登录 后方可回复, 如果你还没有账号请点击这里 注册
网站地图