windows - 在不同位置安装nodejs的最佳方法是什么

标签 windows node.js macos

默认情况下,nodejs 安装在 /usr/local/bin/node 中,但此位置需要 root 访问权限。

如果我随后安装像 grunt-cli 或 yeoman 生成器这样的全局包,它们也需要 root 访问权限。但我不想用 sudo 安装所有全局包。

所以我想为什么不在像 opt/bin/node 这样的地方安装 Node 及其全局包,并授予此位置用户访问权限。

我曾经从nodejs网站下载安装程序,但我无法更改安装位置。所以问题是:

如何将 Nodejs 安装在 OSX 和 Windows 上默认位置之外的位置?

最佳答案

搜索引擎是你的 friend 。

直接取自node docs :

On Windows

The http://nodejs.org/dist/latest/ directory contains executables of the last version of Node.js engine (the engine only, i.e. without npm):

32bit version: http://nodejs.org/dist/latest/node.exe

64bit version: http://nodejs.org/dist/latest/x64/node.exe

The http://nodejs.org/dist/npm/ directory contains the latest .zip archive of npm (such as npm-1.1.16.zip when npm v1.1.16 was the latest).

Manual installation steps:

  1. Make a clean directory and add that directory to your system's PATH variable.

  2. Download the latest node.exe to that directory.

  3. Download the latest npm's .zip file and unpack its contents to the same directory.

Then, with the usual help of PATH, you'll be able to run scripts (node scriptname.js) and install modules (npm install modulename) in any directory.

...就在下面...

Installing on Mac

The http://nodejs.org/dist/latest/ directory contains the latest .pkg package (such as node-v0.6.15.pkg when Node v0.6.15 was the latest).

关于windows - 在不同位置安装nodejs的最佳方法是什么,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24518315/

相关文章:

python - anaconda 在 windows 上安装 python 3.4

javascript - 如何执行条件SQL查询,将结果打包为JSON,并发回客户端?

objective-c - Hook C 函数

windows - 当线程阻塞等待事件时,SysInternals 的进程监视器可以记录吗?

.net - .NET 6.0 可以安装在 Windows 2012 R2 上吗?

windows - 地理定位如何在有线宽带连接的 Windows PC 上工作?

node.js - PEM 例程 :PEM_read_bio:no start line - Unable to decode JWT token

javascript - 网站中的javascript与node.js服务器之间的POST请求

JavaScript 函数——用 wheel 事件调用一次?

macos - GPU负载下CGEventPost的性能较弱