Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Build systems allows you to run your files through external programs without manually
switching between code editor and Terminal. Sublime Text comes with few predefined profiles.
Our mission is to add a new one for JavaScript. We are going to use node.js. Make sure it is
already installed on your device.
{
"cmd": ["/usr/local/bin/node", "$file"],
"selector": "source.js"
}
Windows users
{
"cmd": ["C:/Program Files/nodejs/node.exe", "$file"],
"selector": "source.js"
}
In most cases single node command does the job instead of passing a full path to node. I found
this method more reliable though. If you are not sure where node is installed, just type which
node in Terminal (mac OS) or where node in command prompt (windows users) to get the path.
Save this file as a JavaScript.sublime-build in User directory inside Sublime Text settings
folder.
Time for fun part. Create and save a JavaScript file (to execute a node interpreter, file needs to
be saved), code some super amazing script and click Cmd + B (mac OS) or F7 (Windows). You
can run this task manually from Tools > Build. Sublime Text should automatically run your script
through appropriate build system. If something doesnt work correctly go to Tools > Build
System and make sure that Automatically or JavaScript is selected. Enjoy!
Tweet Share
57Comments pawelgrzybek.com
1 Login
Jointhediscussion
yana_dzhi3monthsago
Hithere!
Thisthingdoesn'tworkonmycomputer(Windows7).
I'vedoneeverythinglikeyousaid:downloadedNode,foundthewayforitincommandprompt,
createdaNewBuildSystem,pasted
{
"cmd":["C:/ProgramFiles/nodejs/node.exe","$file"],
"selector":"source.js"
}
}
thensaveditasaJavaScript.sublimebuildinUserdirectoryinsideSublimeTextsettings.
AfterthatIopenedmysaved.jsfile,pressedF7andnothinghappenes.
Noerrors.Nothing.
Please,helpme!
1 Reply Share
Hi,noworrieswewillmanagedtogetitwork@yana_dzhi
Firsthavealookathelpfulcommentby@VPak
http://disq.us/p/1f5m2jj
Isitanyhelpforyou?Makesurethatyouhaveacorrectpathtonode,fileissavedand
scriptactuallylogssomeoutput
Reply Share
DarkCappuccino7monthsago
Thankyouverymuch.Thisworkedlikeacharm.
1 Reply Share
I'mgladthatithelpedyouout.Haveagreatday@DarkCappuccino
Reply Share
weezillaayearago
Windowsusers:SublimeTextneedstoknowwheretofindaprogramthatcanrunjavascript.Use
WinkeyR,type"cmd",andentertoopencommandprompt.Type"wherenode".Thepathitreturns
iswhatyoushouldtypeintotheconfigfileinSublimeText.Formeitwas"C:/Program
Files/nodejs/node.exe".If"wherenode"complainsaboutnotbeingfound,youshoulddownload
nodejsfromnodejs.org(thenusetheabovestepstopointsublimetotheinstalledexe).
1 Reply Share
Iupdatethisarticlewithsnippetprovidedbyyou.Thanksatonforyourhelpagain.
1 Reply Share
Thankyouforclarification.I'mnotaWindowsusersoitwashardformetoreplytosome
commenters.
1 Reply Share
KaMok>PaweGrzybekayearago
Pleaseupdateyourarticlewiththe"where"alternativeforWindowsuser.ihadto
googlefutheproblemuntilireachedtheendofthepostandsawthis.Woulda
savedmeagood10minutes.
savedmeagood10minutes.
1 Reply Share
Ijustdidit.Thanksforsuggestion.Iwasplaningthatforsometimebecause
itsquitepopularpost.Thanksalot.
1 Reply Share
weezilla>PaweGrzybekayearago
Yourposthelpedmesogladtocontributetoyourblog.Cheers.
1 Reply Share
Pabloamonthago
Thanksforsharing!
Reply Share
RichardBatson2monthsago
Thankyou...thanx:)
Reply Share
Noworries,gladithelps:)
Reply Share
Nikhil4monthsago
Awesome..Workslikecharm!
Reply Share
VPak4monthsago
ThesearestepsforaWindows10Home:
1.Downloadsublimetexthttps://www.sublimetext.com/3(itusuallyshowswhichoneyouneedby
blackdot)
2.Downloadnode.jsathttps://nodejs.org/en/(Recommendedformostusers)
3.gotoTools>BuildSystem>NewBuildSystem
4.saveasJavascriptintheUserdirectoryinsideSublimeTextsettingsfolder
{
"cmd":["C:/ProgramFiles/nodejs/node.exe","$file"],
"selector":"source.js"
}5.tocheckit,followthelastparagraphofthisarticlefrom
Timeforfunpart.Createandsave.....
GOODLUCK!
Reply Share
Thanksalotfordetailedinstruction@VPak.Haveagreatday
Thanksalotfordetailedinstruction@VPak.Haveagreatday
Reply Share
AhmadGinanjar5monthsago
WorkedatSublimeText3,thanksforsharing.:)
Reply Share
I'mgladithelpedyouout.Enjoy:)
Reply Share
knosis8monthsago
Iwaswonderinghowtoprint/savetheoutputofthebuildthatshowedupintheconsole.Modifieda
largebitofjsoninmyfileandwonderinghowtogetitout.
Reply Share
TonyLopes9monthsago
sweet!,thanks!
Reply Share
Zak9monthsago
Hi,completenoobherewiththiskindofstuff...FollowedeverythingupuntilafterIsaveit.I'mnot
reallysurewhattodoaftersavingitorhowtoproceed.I'musingwindows10bytheway.Ialso
downloadedthe"Current"versionofnode.js,Idon'tknowifthataffectsanything.
Reply Share
HiZak.Aslongasyoudidallthestepscorrectlyandsavedthebuildconfigfileyoushould
beabletoexecuteyourjsfileinsideSublimeText.Makesurethatyourfileextensionis.js.
ThenmakesurethatinmenuTools>Buildsystemis"Automatic"or"JavaScript".Then
insideyourfilehitCtrl+b.Itshouldexecuteyourfilewithnoissue.Fileneedstobesaved
onharddrivebeforehand.
Reply Share
Zak>PaweGrzybek9monthsago
Hi,thanksforyourquickreply,yourlastsentenceiswhatIdidn'tdo.Ijustopeneda
newtabandsaveditasxyz.jsandretriedanditworked.Thankyousomuchforthe
tutorial.
Reply Share
Noworries,I'mgladImanagedtohelp:)
Reply Share
DelanteLeeBess9monthsago
Thanks!WorksonbothmyMacandWindowslaptops.
Reply Share
I'mreallygladthatyoufoundituseful.Enjoy:)
Reply Share
RickEnciso9monthsago
Thanks!!
IhadnodeinstalledthroughNVMsoitdidn'tworkformeatfirst,soIjustswitchedthepathtonode
likethis:
firstofallyoucangetthecorrectpathbytyping$whichnodeinyourterminal
//original
{
"cmd":["/usr/local/bin/node","$file"],
"selector":"source.js"
}
//nvmpath
{
"cmd":["/Users/user/.nvm/versions/node/v4.4.7/bin/node","$file"],
"selector":"source.js"
}
Reply Share
Exactly.Aslongasthenodepathiscorrectitsgonnawork.ThanksforcontributionRick!
Reply Share
DmitriyShesterkin10monthsago
Thankyouverymuch!
Reply Share
I'mgladyoufoundthistutorialhelpful!
1 Reply Share
MuhammadBinQasimayearago
Hello.....yousaidthatweneedtofindtherightpath.whatdoyoumeanbythat??
theproblemisthis.andyousaidfindtherightpath....canyoupleasedirectus
[WinError2]Thesystemcannotfindthefilespecified
[cmd:['/usr/local/bin/node','C:\\Users\\Muhammad\\Desktop\\1.js']]
[dir:C:\Users\Muhammad\Desktop]
[path:
C:\Windows\system32C:\WindowsC:\Windows\System32\WbemC:\Windows\System32\WindowsPowerS
Files\Intel\WiFi\bin\C:\ProgramFiles\CommonFiles\Intel\WirelessCommon\C:\ProgramFiles
(x86)\ATITechnologies\ATI.ACE\CoreStaticC:\ProgramFiles\Intel\WiFi\bin\C:\Program
Files\CommonFiles\Intel\WirelessCommon\]
[Finished]
Reply Share
weezilla>MuhammadBinQasimayearago
Seemycommentabove.
Reply Share
phamcongayearago
Canyoutellmewhichkindofthemeyouused?Itsverynice.Thank!
Reply Share
Hello.Itisa"Spacegray".Feelfreetograbmywholeconfigurationfilethatisavailablehere:
https://github.com/pawelgrz...
Reply Share
phamcong>PaweGrzybekayearago
Thanksomuch.I'lltryit))
1 Reply Share
Adeyemiayearago
WorksonMacperfectly!
Reply Share
I'mgladithelped.Haveagreatday!
Reply Share
Avatar Thiscommentwasdeleted.
I'mgladitworksforyou.Snippetabovehasdoublequotes:)
Reply Share
Avatar Thiscommentwasdeleted.
letsomeString=`2+2=${2+2}`;
Reply Share
amireghbalianayearago
[WinError2]Thesystemcannotfindthefilespecified
[cmd:['C:\\Users\\username\\node.exe','']]
[dir:C:\ProgramFiles(x86)\SublimeText3]
[path:C:\ProgramFiles(x86)\NVIDIA
Corporation\PhysX\CommonC:\Windows\system32C:\WindowsC:\Windows\System32\WbemC:\Windows
Files(x86)\CommonFiles\Acronis\SnapAPI\C:\ProgramFiles(x86)\MicrosoftSQL
Server\100\Tools\Binn\C:\ProgramFiles\MicrosoftSQLServer\100\Tools\Binn\C:\Program
Files\MicrosoftSQLServer\100\DTS\Binn\C:\Program
Files\MATLAB\R2014b\runtime\win64C:\ProgramFiles\MATLAB\R2014b\binC:\Program
Files\MATLAB\R2014b\polyspace\binC:\Program
Files\nodejs\C:\Users\Amir\AppData\Roaming\npm]
[Finished]
ihavethesameproblemhere
cananybodyhelpmeplz?
Reply Share
weezilla>amireghbalianayearago
Seemycommentaboveaspossiblesolution.
Reply Share
minayearago
heythere,itriedyourinstructionsforsublimetext2onmac,anditworked:Dbutnowi'mtryingit
forsublimetext3onwindows7,i'mgettingthiserrorwhenisavemyjsfile:
[WinError2]Thesystemcannotfindthefilespecified
[cmd:['/usr/local/bin/node','C:\\Users\\user\\Desktop\\js\\recursivefunction.js']]
[dir:C:\Users\user\Desktop\js]
[path:
C:\Windows\system32C:\WindowsC:\Windows\System32\WbemC:\Windows\System32\WindowsPowerS
Files(x86)\Skype\Phone\C:\ProgramFiles\nodejs\C:\Users\user\AppData\Roaming\npm]
[Finished]
i'mnotsurewhatswrong..isitafaultyinstallofnodejsthatiscausingthis?:(
Reply Share
VNamHng>minayearago
itshouldbesomethinglike'C:/ProgramFiles/nodejs/node'insteadof'/usr/local/bin/node'
1 Reply Share
Hello.Itlookslikeyouhaveawrongpathtonodeinsideyourbuildsystem.Youneedtofind
acorrectpathwhereyournodeisinstalledandreplacethisstring"/usr/local/bin/node"with
yourpath.
Reply Share
DCDudeayearago
Thankyou!Ilearnedhowtouse"which",too!
Reply Share
I'msupergladthatIhelped.Enjoy!
Reply Share
billyzhangayearago
Itworksforme.Thankyou.StarttousenodeinSublimeText3now.Iamabletorunasingle
node.jsfileforsomefunctionvalidation.
Reply Share
I'mgladithelped.Enjoy!
Reply Share
Loadmorecomments