Adding a JS build-system to Sublime

  • A+
所属分类:sublime text

Frustratingly, the Sublime Text editor doesn’t set up a build system for JavaScript the way it does for Ruby and some other languages. Fortunately, it’s an easy problem to fix. Assuming your JS interpreter is Node.js, these are the steps to set it up:

  1. Open the Tools>Build System menu and select “new build system”
  2. Name it Node, and a new file called node.sublime-build will be created.
  3. Add the following data to it and save:
{
  "cmd": ["node", "$file", "$file_base_name"],
  "working_dir": "${project_path:${folder}}",
  "selector": "*.js"
}
  • Restart Sublime
  • Select Node as the build system for your file and hit cmd + b to build from Sublime!

Here’s an example JS file to run:

console.log("hello world");
weinxin
我的微信
欢迎来撩!!

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: