sublime3 配置node build环境

No matching processes belonging to you were found
/bin/sh: node: command not found
[Finished in 0.1s with exit code 127]
[cmd: ['killall node; node /Users/jachin/Project/Es6/src/Node/fs.js']]
[dir: /Users/jachin/Project/Es6/src/Node]
[path: /usr/bin:/bin:/usr/sbin:/sbin]



在Sublime上添加了nodejs插件,本地也安装了node,配置也按照网上的说明写了
包括:

nodejs-sublime-build
 {
  "shell_cmd": "make",
  "cmd": ["/usr/local/bin/node", "$file"],
  "file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
  "selector": "source.js",
  "shell":true,
  "encoding": "utf-8",
  "windows":
    {
      "cmd": ["taskkill /F /IM node.exe & node", "$file"]
    },
  "linux":
    {
        "cmd": ["killall node; node", "$file"]
    }
}


nodejs-sublime-setting
 {
  // 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
}

bashrc文件

# System-wide .bashrc file for interactive bash(1) shells.
if [ -z "$PS1" ]; then
   return
fi
PS1='\h:\W \u\$ '
# Make bash check its window size after a process completes
shopt -s checkwinsize
[ -r "/etc/bashrc_$TERM_PROGRAM" ] && . "/etc/bashrc_$TERM_PROGRAM"
#source ~/.nvm/nvm.sh
export PATH="$HOME/local/bin/node:$PATH"
#export PATH="~/.nvm/versions/node/v5.3.0/bin:$PATH"

**

但是还是报错,请问是为什么?是我地址配的不对还是环境变量配的不对咯?

阅读 12.2k
1 个回答

sublime text 3自带build的系统,只需要在tools->build system-> new build system...
写入:

{
  "shell_cmd": "node $file",
  "selector": "source.js"
}

保存为 node.sublime-build,就可以使用cmd+shift+b调出窗口选择node编译.

keymap绑定按键:

{
    "keys": ["ctrl+c"],
    "command": "exec",
    "args": {
      "kill": true
    }
  }

就可以使用快捷键ctrl+c关闭,或者手动点选tools-> cancel build中断。

需要编译es6的代码的话可以考虑用babel,build tools替换成

{
  "shell_cmd": "babel-node  $file",
  "selector": "source.js"
}
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题
宣传栏