简体   繁体   English

开启时未安装Raspberry PI 2 nodejs

[英]Raspberry PI 2 nodejs not installed when I turn it on

Well, i'm working with nodejs in a Raspberry Pi 2. I installed it using nvm ( https://github.com/creationix/nvm ) using the command: 好吧,我正在Raspberry Pi 2中使用nodejs。我使用nvm( https://github.com/creationix/nvm )使用以下命令安装了它:

wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.29.0/install.sh | bash

Then, I tested if I could execute from the terminal the programs node and npm and I could, but, when I reboot the Raspberry PI 2 I type node or npm and the terminal prompts "command not found", so I have to go and type nvm install v4.2.2 on each startup. 然后,我测试了是否可以从终端执行程序节点和npm,并且可以执行,但是,当我重新启动Raspberry PI 2时,我键入node或npm并且终端提示“找不到命令”,所以我必须去在每次启动时键入nvm install v4.2.2

Another problem that I have is that I can't execute sudo nvm, or sudo node. 我遇到的另一个问题是我无法执行sudo nvm或sudo节点。

I have the following questions: 我有以下问题:

  • Have any of you had the same problem, and have you solved it? 你们中有人遇到过同样的问题吗,您解决了吗?
  • How can I uninstall nvm? 如何卸载nvm?
  • How can I use nvm with sudo? 如何在sudo中使用nvm?

NVM is not on your PATH respectively it isn't sourced on reboot. NVM不在您的PATH上,也不是在重新启动时获取的。

You have to follow the manual installation guide on https://github.com/creationix/nvm . 您必须遵循https://github.com/creationix/nvm上的手动安装指南。

To activate nvm, you need to source it from your shell: 要激活nvm,您需要从外壳中获取它:

. ~/.nvm/nvm.sh 〜/ .nvm / nvm.sh

Add these lines to your ~/.bashrc, ~/.profile, or ~/.zshrc file to have it automatically sourced upon login: 将这些行添加到您的〜/ .bashrc,〜/ .profile或〜/ .zshrc文件中,以便在登录时自动获取该文件:

export NVM_DIR="$HOME/.nvm" [ -s "$NVM_DIR/nvm.sh" ] && . 导出NVM_DIR =“ $ HOME / .nvm” [-s“ $ NVM_DIR / nvm.sh”] &&。 "$NVM_DIR/nvm.sh" # This loads nvm “ $ NVM_DIR / nvm.sh”#这将加载nvm

But you don't have to use nvm on a raspberry Pi, except you are really using many different versions of node. 但是您不必在树莓派上使用nvm,除非您确实使用了许多不同版本的node。 Otherwise i would recommend you to only install one version of node. 否则,我建议您仅安装一个版本的节点。 Node comes with npm as default. Node默认带有npm。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM