node.js - Nodejs 构建 sublime-text2

标签 node.js build sublimetext2

我正在尝试使用 sublime-text 2,已经为 Windows 安装了 Nodejs,通过包控制安装了 Nodejs 插件,但出现以下错误:

ERROR: The process "node.exe" not found.

The filename, directory name, or volume label syntax is incorrect.

[Finished in 0.1s with exit code 1]

我已将 NODE_PATH 设置为我的用户环境变量:C:\Program Files\nodejs\node.exe 在我的系统变量PATH中有:C:\Program Files\nodejs\

我的 Nodejs.sublime-settings 设置如下:

{
  // 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": "C:/Program Files/nodejs/node.exe",
  // Same for NPM command
  "npm_command": false,
  // as 'NODE_PATH' environment variable for node runtime
  "node_path": "C:/Program Files/nodejs/node.exe",

  "expert_mode": false,

  "ouput_to_new_tab": false
}

我的 Nodejs.sublime-build 设置如下:

{
  "cmd": ["C:/Program Files/nodejs/node.exe", "$file"],
  "file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
  "selector": "source.js",
  "shell":true,
  "encoding": "cp1252",
  "windows":
    {
        "cmd": ["taskkill /F /IM node.exe & node", "$file"]
    },
  "linux":
    {
        "cmd": ["killall node; node", "$file"]
    }
}

作为旁注,我正在使用 JSHint,它使用相同路径(即“C:/Program Files/nodejs/node.exe”)使用 Nodejs,并且 JSHint 有效! 知道为什么我不能使用 Nodejs 构建系统吗? 谢谢

最佳答案

暂时尝试将构建系统设置为以下内容:

{
  "cmd": ["C:/Program Files/nodejs/node.exe", "$file"],
  "file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
  "selector": "source.js",
  "shell":true,
}

因为您有一个特定于 Windows 的部分,所以它在构建系统的第一行运行该部分而不是 "cmd"。我怀疑 taskkill 命令有问题。

如果这确实有效,并且您觉得需要将 taskkill 部分放回那里,请尝试像这样重组它:

"windows":
    {
        "cmd": ["taskkill", "/F", "/IM", "node.exe", "&", "C:/Program Files/nodejs/node.exe", "$file"],
        "shell": true
    }

显然,您根本不需要其中的 linux 部分。我不太确定 Windows 上的语法,您可能需要有两个符号 && 而不是一个 - 我知道在 OS X 和 Linux 系统上就是这种情况。

祝你好运!

关于node.js - Nodejs 构建 sublime-text2,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21949068/

相关文章:

tfs - 如何获取 TFS 构建状态通知?

maven - 防止 Maven 跳过测试(默认 = 跳过)

sublimetext2 - Sublime Text 2 将颜色粘贴到 MS Word

java - Sublime Text2如何添加run java标签?

node.js - node.js 中的 $_SERVER ['SERVER_ADDR' '] 是什么?

node.js - Couchbase 几秒后超时

java - Gradle 构建错误 - 程序类型已存在

node.js - 类型错误 : Cannot read property 'substr' of undefined - source-node. js

node.js - 使用 node.js 包含 HTML block

sublimetext2 - 如何在Visual Studio Code中粘贴和缩进?