NPM安装给安装Express带来错误

NPM安装给安装Express带来错误,第1张

NPM安装给安装Express带来错误

Node非常容易手动安装。我也喜欢这样做,因为切换版本真的很容易。

这也很棒,因为您无需向添加一些外部软件包存储库

apt
,并且在节点发布新版本时不必等待这些存储库更新。您可以在发布更新后立即获得更新。

# make a `~/.nodes/ foldermkdir -p ~/.nodes && cd ~/.nodes# download the binaries from nodejs.org# in this case, here's the linux versioncurl -O http://nodejs.org/dist/v0.10.12/node-v0.10.12-linux-x64.tar.gz# extracttar -xzf node-v0.10.12-linux-x64.tar.gz# rename folder to 0.10.12mv node-v0.10.12-linux-x64 0.10.12# create a `current` symlinkln -s 0.10.12 current# prepend ~/.nodes/bin to your path# you'll want to save this in ~/.bashrc or ~/.zshrc or somethingexport PATH="~/.nodes/current/bin:$PATH"# cleanuprm ~/.nodes/node-v0.10.12-linux-x64.tar.gz

最好的部分是,您可以对其他任何版本的节点重复该模式,随时更改

current
符号链接以切换您正在运行的版本,然后您就可以开始使用

% node --versionv0.10.12% npm --version1.2.32# switch versions to (e.g.) 0.10.5% cd ~/.nodes && rm current && ln -s 0.10.5 current% node --versionv0.10.5% npm --version1.2.18

编写可执行脚本时的其他指针

制作可执行文件

% touch ~/somefile && chmod +x ~/someifle && nano ~/somefile

文件内容

#!/usr/bin/env nodeconsole.log(process.version);

运行

% ./somefilev0.10.12


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/5476873.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-12
下一篇 2022-12-12

发表评论

登录后才能评论

评论列表(0条)

保存