默认情况下,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:
Make a clean directory and add that directory to your system's PATH variable.
Download the latest node.exe to that directory.
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/