Sublime Text 2 - 使用 Node.js 构建 javascript
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20597182/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Sublime Text 2 - making javascript build with Node.js
提问by user3104891
I'm trying to make a Javascript build system in Sublime Text 2 using Node.js. The problem is I don't know where Node.js is installed on my mac (I installed it with mac installer and am running Mountain Lion) or how to properly assign a path variable to find it.
我正在尝试使用 Node.js 在 Sublime Text 2 中创建一个 Javascript 构建系统。问题是我不知道 Node.js 在我的 Mac 上的安装位置(我用 mac 安装程序安装了它并且正在运行 Mountain Lion)或者如何正确分配路径变量来找到它。
回答by MattDMo
If you haven't already, install Package Controlin Sublime, then install the Nodejs
plugin. This should get you a lot farther than trying to build everything from scratch.
如果您还没有,请在 Sublime 中安装 Package Control,然后安装Nodejs
插件。与尝试从头开始构建所有内容相比,这应该会让您走得更远。
Once Nodejs is installed, open Preferences -> Package Settings -> Nodejs -> Settings - Default
andSettings - User
. Copy the entire contents of Default
to User
so you can edit it, then close Default
. (If you editDefault
, any changes will be overwritten on upgrade.) Change "node_command"
and "npm_command"
from false
to the full path returned by running which node
and which npm
from Terminal.app.
一旦安装的NodeJS,打开Preferences -> Package Settings -> Nodejs -> Settings - Default
和Settings - User
。复制Default
to的全部内容User
以便您可以对其进行编辑,然后关闭Default
。(如果您编辑Default
,任何更改都将在升级时被覆盖。)更改"node_command"
和"npm_command"
从false
运行which node
和which npm
从 Terminal.app返回的完整路径。
For example, if which node
returns /usr/local/bin/node
, and which npm
returns /usr/local/bin/npm
, then your settings file should look like this:
例如,如果which node
返回/usr/local/bin/node
,并which npm
返回/usr/local/bin/npm
,则您的设置文件应如下所示:
{
// save before running commands
"save_first": true,
// if present, use this command instead of plain "node"
// e.g. "/usr/bin/node" or "C:\bin\node.exe"
"node_command": "/usr/local/bin/node",
// Same for NPM command
"npm_command": "/usr/local/bin/npm",
// as 'NODE_PATH' environment variable for node runtime
"node_path": false,
"expert_mode": false,
"ouput_to_new_tab": false
}
Save the file, and you should now be able to successfully use the commands in Tools -> Nodejs
.
保存文件,您现在应该可以成功使用Tools -> Nodejs
.