NPM安装给安装Express带来错误
当我给出命令时,npm install express
它引发以下错误。在Ubuntu机器上
gaurav@gaurav-Mini-Monster:~/TestScripts$ sudo npm install -g expressnpm ERR! error installing express@3.3.3 Error: Unsupported
npm ERR! error installing express@3.3.3 at checkEngine (/usr/local/lib/node_modules/npm/lib/install.js:493:14)
npm ERR! error installing express@3.3.3 at Array.0 (/usr/local/lib/node_modules/npm/node_modules/slide/lib/bind-actor.js:15:8)
npm ERR! error installing express@3.3.3 at LOOP (/usr/local/lib/node_modules/npm/node_modules/slide/lib/chain.js:15:13)
npm ERR! error installing express@3.3.3 at chain (/usr/local/lib/node_modules/npm/node_modules/slide/lib/chain.js:20:4)
npm ERR! error installing express@3.3.3 at installOne_ (/usr/local/lib/node_modules/npm/lib/install.js:470:3)
npm ERR! error installing express@3.3.3 at installOne (/usr/local/lib/node_modules/npm/lib/install.js:411:3)
npm ERR! error installing express@3.3.3 at /usr/local/lib/node_modules/npm/lib/install.js:347:9
npm ERR! error installing express@3.3.3 at /usr/local/lib/node_modules/npm/node_modules/slide/lib/async-map.js:54:35
npm ERR! error installing express@3.3.3 at Array.forEach (native)
npm ERR! error installing express@3.3.3 at /usr/local/lib/node_modules/npm/node_modules/slide/lib/async-map.js:54:11
npm ERR! error rolling back express@3.3.3 Error: UNKNOWN, Unknown error '/usr/local/lib/node_modules/express'
npm ERR! Unsupported
npm ERR! Not compatible with your version of node/npm: connect@2.8.3
npm ERR! Required: {"node":">= 0.8.0"}
npm ERR! Actual: {"npm":"1.0.106","node":"0.5.11-pre"}
npm ERR!
npm ERR! System Linux 3.2.0-48-generic-pae
npm ERR! command "node" "/usr/local/bin/npm" "install" "-g" "express"
npm ERR! cwd /home/gaurav/TestScripts
npm ERR! node -v v0.5.11-pre
npm ERR! npm -v 1.0.106
npm ERR! code ENOTSUP
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /home/gaurav/TestScripts/npm-debug.log
npm not ok
我也试过
sudo npm install expressnpm install -g express
sudo npm install -g express
没事。
回答:
Node非常容易手动安装。我也喜欢这样做,因为切换版本真的很容易。
这也很棒,因为您无需向添加一些外部软件包存储库apt
,并且在节点发布新版本时不必等待这些存储库更新。您可以在发布更新后立即获得更新。
# make a `~/.nodes/ foldermkdir -p ~/.nodes && cd ~/.nodes
# download the binaries from nodejs.org
# in this case, here's the linux version
curl -O http://nodejs.org/dist/v0.10.12/node-v0.10.12-linux-x64.tar.gz
# extract
tar -xzf node-v0.10.12-linux-x64.tar.gz
# rename folder to 0.10.12
mv node-v0.10.12-linux-x64 0.10.12
# create a `current` symlink
ln -s 0.10.12 current
# prepend ~/.nodes/bin to your path
# you'll want to save this in ~/.bashrc or ~/.zshrc or something
export PATH="~/.nodes/current/bin:$PATH"
# cleanup
rm ~/.nodes/node-v0.10.12-linux-x64.tar.gz
最好的部分是,您可以对其他任何版本的节点重复该模式,随时更改current
符号链接以切换您正在运行的版本,然后您就可以开始使用
% node --versionv0.10.12
% npm --version
1.2.32
# switch versions to (e.g.) 0.10.5
% cd ~/.nodes && rm current && ln -s 0.10.5 current
% node --version
v0.10.5
% npm --version
1.2.18
编写可执行脚本时的其他指针
制作可执行文件
% touch ~/somefile && chmod +x ~/someifle && nano ~/somefile
文件内容
#!/usr/bin/env nodeconsole.log(process.version);
运行
% ./somefilev0.10.12
以上是 NPM安装给安装Express带来错误 的全部内容, 来源链接: utcz.com/qa/403660.html