Sublime Text 2 - 使用Node.js构建javascript [英] Sublime Text 2 - making javascript build with Node.js

查看:91
本文介绍了Sublime Text 2 - 使用Node.js构建javascript的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Node.js在Sublime Text 2中创建一个Javascript构建系统。问题是我不知道我的mac上安装了Node.js的位置(我用mac安装程序安装它并运行Mountain Lion)或者如何正确分配路径变量来查找它。

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.

推荐答案

如果您还没有,请安装包控件在Sublime中,然后安装 Nodejs 插件。这比你从头开始构建所有内容要远得多。

If you haven't already, install Package Control in Sublime, then install the Nodejs plugin. This should get you a lot farther than trying to build everything from scratch.

安装Nodejs后,打开首选项 - >包装设置 - > Nodejs - >设置 - 默认 设置 - 用户。将默认的全部内容复制到用户,以便您可以编辑它,然后关闭默认。 (如果您编辑 默认升级时将覆盖任何更改。)更改 node_commandnpm_command false 到运行<$返回的完整路径来自Terminal.app的c $ c>哪个节点和哪个npm

Once Nodejs is installed, open Preferences -> Package Settings -> Nodejs -> Settings - Default and Settings - User. Copy the entire contents of Default to User so you can edit it, then close Default. (If you edit Default, 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.

例如,如果哪个节点返回 / usr / local / bin / node 哪个npm 返回 / usr / local / bin / npm ,然后你的设置文件应该是这样的:

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:

{
    // 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
}

保存文件,您现在应该能够成功使用工具中的命令 - > Nodejs

Save the file, and you should now be able to successfully use the commands in Tools -> Nodejs.

这篇关于Sublime Text 2 - 使用Node.js构建javascript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆