如果我尝试与Node一起安装NPM。 js使用以下命令:
sudo apt-get install nodejs npm
我遇到以下错误:
pi@raspberrypi ~ $ sudo apt-get install nodejs npm
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
nodejs : Breaks: npm (< 1.1.4~dfsg-2~) but 1.1.4~dfsg-1 is to be installed
npm : Depends: node-semver but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
我很漂亮软件包管理如何与基于Debian的Linux操作系统一起使用的新知识,并且对node.js社区如何构建其特定软件包一无所知。值得注意的是,自行安装node.js可以正常工作,如果我尝试自行安装NPM,这就是我所得到的。
pi@raspberrypi ~ $ sudo apt-get install npm
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
npm : Depends: nodejs but it is not going to be installed
Depends: nodejs-dev but it is not going to be installed
Depends: node-request but it is not going to be installed
Depends: node-mkdirp but it is not going to be installed
Depends: node-minimatch but it is not going to be installed
Depends: node-semver but it is not going to be installed
Depends: node-ini but it is not going to be installed
Depends: node-graceful-fs but it is not going to be installed
Depends: node-abbrev but it is not going to be installed
Depends: node-nopt but it is not going to be installed
Depends: node-fstream but it is not going to be installed
Depends: node-rimraf but it is not going to be installed
Depends: node-tar but it is not going to be installed
Depends: node-which but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
我'我不确定,但是我的直觉告诉我,这与
node-semver
软件包有关。如果我自己安装nodejs
软件包,然后尝试安装node-semver
,则这是我得到的输出。pi@raspberrypi ~ $ sudo apt-get install node-semver
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
node-semver : Depends: nodejs but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
任何指针?
#1 楼
尝试一起安装它们: sudo apt-get install nodejs npm node-semver
#2 楼
这是在树莓派上安装NodeJ的最佳方法,我很喜欢,而且我认为这很容易做到,以后进行更新时,只需用新版本替换'/ opt / nodejs'文件夹: br />wget https://nodejs.org/dist/v4.2.4/node-v4.2.4-linux-armv6l.tar.gz
sudo mv node-v4.2.4-linux-armv6l.tar.gz /opt
cd /opt
sudo tar -xzf node-v4.2.4-linux-armv6l.tar.gz
sudo mv node-v4.2.4-linux-armv6l nodejs
sudo rm node-v4.2.4-linux-armv6l.tar.gz
sudo ln -s /opt/nodejs/bin/node /usr/bin/node
sudo ln -s /opt/nodejs/bin/npm /usr/bin/npm
请注意,最新的Raspberry版本也有arm71版本。
#3 楼
Adafruit提供(相对)当前节点和npm。在没有找到有用的编译器后,这对我使用了许多软件包(express,body-parser,pg)#4 楼
我发现在任何Raspberry PI(零至3)上获得NPM(以及最新版本的Node.js)的最简单方法是使用“ NVM”(节点版本管理器)。要安装NVM :
wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.31.6/install.sh | bash
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm
一旦安装,您可以随时下载最新版本的Node.js,例如:
nvm install node
完成!
验证是否已安装NPM:
npm --version
评论
这对我的pi 3b +来说效果很好,第一个解决方案安装了npm 1.6,并且在安装软件包时一直出错。 NVM使一切正常运行。
– sirclesam
19年6月10日在23:40
#5 楼
我在pi 3上运行raspbian jessie。该节点已预安装在映像中,但npm并未安装。安装npm时遇到了挑战,该线程帮助我获得了线索。我pi@raspberrypi:~ $ **sudo apt-get install nodejs npm node-semver**
Reading package lists... Done
Building dependency tree
Reading state information... Done
nodejs is already the newest version.
nodejs set to manually installed.
The following extra packages will be installed:
gyp libc-ares-dev libjs-node-uuid libjs-underscore libssl-dev
libssl-doc libv8-3.14-dev node-abbrev node-ansi node-ansi-color-table
node-archy node-async node-block-stream node-combined-stream
node-cookie-jar node-delayed-stream node-forever-agent node-form-data
node-fstream node-fstream-ignore node-github-url-from-git node-glob
node-graceful-fs node-gyp node-inherits node-ini node-json-stringify-safe
node-lockfile node-lru-cache node-mime node-minimatch
node-mkdirp node-mute-stream node-node-uuid node-nopt node-normalize-package-data
node-npmlog node-once node-osenv node-qs node-read node-read-package-json
node-request node-retry node-rimraf node-sha node-sigmund node-slide
node-tar node-tunnel-agent node-underscore node-which nodejs-dev
Suggested packages:
node-hawk node-aws-sign node-oauth-sign node-http-signature
The following NEW packages will be installed:
gyp libc-ares-dev libjs-node-uuid libjs-underscore libssl-dev
libssl-doc libv8-3.14-dev node-abbrev node-ansi node-ansi-color-table
node-archy node-async node-block-stream node-combined-stream
node-cookie-jar node-delayed-stream node-forever-agent node-form-data
node-fstream node-fstream-ignore node-github-url-from-git node-glob
node-graceful-fs node-gyp node-inherits node-ini node-json-stringify-safe
node-lockfile node-lru-cache node-mime node-minimatch
node-mkdirp node-mute-stream node-node-uuid node-nopt node-normalize-package-data
node-npmlog node-once node-osenv node-qs node-read node-read-package-json
node-request node-retry node-rimraf node-semver node-sha node-sigmund
node-slide node-tar node-tunnel-agent node-underscore node-which
nodejs-dev npm
0 upgraded, 55 newly installed, 0 to remove and 0 not upgraded.
Need to get 2,222 kB/3,708 kB of archives.
After this operation, 13.3 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
**Err http://mirrordirector.raspbian.org/raspbian/ jessie/main libssl-dev armhf 1.0.1k-3+deb8u2
404 Not Found [IP: 5.153.225.207 80]
Err http://mirrordirector.raspbian.org/raspbian/ jessie/main libssl-doc all 1.0.1k-3+deb8u2
404 Not Found [IP: 5.153.225.207 80]
E: Failed to fetch
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?**
pi@raspberrypi:~ $
评论
您能否编辑您的帖子以使其更具可读性。文字墙真的必要吗?
–加纳马♦
16年4月24日在15:01
#6 楼
如果您遇到二进制程序包的问题,我建议您自己编译它,这样可以更好地了解出现故障的情况/二进制程序包可能用于其他类型的处理器(不是ARM)。我建议您查阅https://gist.github.com/3301813以获取有关Raspberry Pi NodeJS编译说明的信息。
评论
谢谢本。我以前看过那篇文章。我以为NPM可能与Node.js源代码树分开?
–米奇·丹尼(Mitch Denny)
2012年12月27日下午2:39
NPM在源码github.com/isaacs/npm处是单独的,但是nodejs的最新版本通常捆绑了npm。
– Ben Evans
2012年12月27日在21:13
#7 楼
正如Ben指出的那样,我建议您在Raspberry Pi上自行编译Node.js。由于0.8.10(或大约),这是没有可能的事。只需$ ./configure
$ make
$ sudo make install
就是这样。然后将安装包含
npm
的Node.js。评论
感谢Golo。 Minitech提供了一个对我来说更好的答案。 Raspberry Pi的运行速度很慢,因此我认为构建然后安装会比较麻烦。
–米奇·丹尼(Mitch Denny)
2012年12月27日23:05
请查看使用apt-get安装的Node.js版本,然后将其与Node.js的当前版本进行比较,您会知道为什么我不建议使用apt-get ... ;-)
– Golo Roden
13年1月3日,12:38
我已经制作了一些预编译的tarball,如果您真的不想等待源代码编译,可以在Raspberry Pi上使用。 gist.github.com/3245130
–亚当M-W
13年6月18日在4:37
#8 楼
您所要做的就是输入pi@raspberrypi ~ $ sudo apt-get install nodejs npm node-semver
它对我有用,我能够毫无错误地安装它,并且应该可以与程序一起使用!
评论
请更精确:您以这种方式安装了哪个版本的节点,软件包的来源是什么(是否添加了新的软件包?),安装了什么操作系统,安装了哪个rPi版本,它是什么节点架构( armv6,v7)。您的回答可能会解决一些问题,但我们不知道该怎么做,因此没人会使用它。
–博世
16-09-25在12:36
#9 楼
尝试关注此帖子。我设法在/ opt / node / npm上运行npm,但是当我将其复制到/ usr / bin /时,它会丢失'npmlog'。评论
IT部门最好将步骤复制到答案中,同时在源中分配其他信息,以防源站点出现故障,页面被删除或移动等情况。
– Tevo D
13年8月23日在13:07
评论
这个答案是最新的。
– Uriel
15年12月31日在13:53
到目前为止,这是最好的解决方案,但我刚刚找到了另一个使用nvm(节点版本管理器)的解决方案,它可以使您轻松更新节点,但同时也可以使用不同的版本。它们共享符号链接步骤,以允许所有用户访问节点。这里有一个简短的教程losant.com/blog/how-to-install-nodejs-on-raspberry-pi,其中包含避免符号链接问题的解决方案:stackoverflow.com/a/29903645/3480671
–博世
16-09-25在13:29
注意:/ usr / local / bin对于在/ opt中由本地管理员管理的符号转储到本地管理员管理的符号链接会更合适
–JamesTheAwesomeDude
18年6月16日在12:53
它对我有用,我真正遇到的问题是NPM并未随Node一起提供,但NPM并没有独立存在,因此安装了NPM,但现在Node不起作用
–雅各布·施耐德(Jacob Schneider)
19年2月26日在6:31