How to run node app with sublime text

前端 未结 6 589
旧巷少年郎
旧巷少年郎 2021-02-03 12:38

How would you run node app with sublime text? Like this, open the file app.js in sublime, go to menu->tools->build, and it just runs. Simple like that

6条回答
  •  庸人自扰
    2021-02-03 13:07

    If you want to fix the plugin's path yourself. One option is changing Nodejs.sublime-build. It's located in the packages directory of sublime:

    Mac: ~/Library/Application Support/Sublime Text 2/Packages/Nodejs/Nodejs.sublime-build 
    
    Linux: ~/.config/sublime-text-2/Packages/Nodejs/Nodejs.sublime-build
    

    Note: On latest OS X versions the Library folder is hidden. If that's the case, from the menu select Go > Go to Folder... and type ~/Library.

    Change "cmd": ["node", "$file"] to "cmd": ["/usr/local/bin/node", "$file"]
    
    {
      "cmd": ["/usr/local/bin/node", "$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"]
        }
    }
    

    Lastly, open your *.js file and press command + b. Everything should just work fine now.

    Linux Users: This file is identical across all operating systems. Finding the path to Nodejs.sublime-build may require running a search. In most cases it's located in ~/.config/sublime-text-2/Packages/Nodejs/Nodejs.sublime-build

提交回复
热议问题