Sublime 2 text - build during saving a .js file - node.js

Please, is there an option, how to disable auto-build, when i am trying to save a .js file?
I was elaborating a node.js + express tutorial, and all the time I've saved the file, the build was starting the node.exe binary, what is something that i dont want, only solution was to tick the Build system for example for JSLint, but it still tries to build when I'm saving a file.
I know there is an tick option in Tools -> Save all on Build, but i cant find the inverse option - disable Build all on save.
I've installed the Node package for Sublime 2, and even when its disabled the build system Nodejs trys to build during the saving proces (ctrl+s)
thanks for all hints!
Here are my custom user packages:
"installed_packages":
[
"Dart",
"JavaScript Console",
"JavaScript Snippets",
"JSLint",
"Mocha Runner",
"Mocha Snippets",
"Nodejs",
"Package Control",
"Require Node.js Modules Helper",
"sublime-jslint"
],

This problem was caused by the nodejs package for sublime text 2 - after removing the package completly (not just disabling) I got an error msg when trying to save the app.js
pressed CTRL+S error: Error trying to parse build system: No data in
C:\Users\username\AppData\Roaming\Sublime Text
2\Packages\Nodejs\Nodejs.sublime-build:1:1
Problem solved, but I still don't know, why sublime was calling nodejs.sublime-build direct after saving the app.js file.
Strange behavior, maybe a bug or a unwanted feature (When a file is saved, the pre-set build system is called direct after the save)
Problem solved by removing the whole package.

If you go to the Tools menu, does the Build option have the shortcut Ctrl-S next to it? If so, your key-mapping probably got messed up at some point. Put the following line in your Key Bindings - User file (in the Preferences menu) and save it by selecting File -> Save (double check that its shortcut is still Ctrl-S as well).
{ "keys": ["ctrl+b"], "command": "build" },
Remove the , at the end if it's the last (or only) line in your user keymap.
You can go to Preferences -> Package Settings and through the menu options for each entry, looking for additional keymap definitions. Also, check Preferences -> Key Bindings (Default) and search for build to see if it got changed there to ctrl+s. If so, feel free to change it back to b.

Have you verified "save" is actually being run on ctrl+s? If not, open up the console ctrl+backtick and enter sublime.log_commands(True) Then press ctrl+s If save is being run, you should see command: save. If not, one of the plugins is grabbing the ctrl+s keybinding before it falls back to default.
If save is running, on of the plugins probably has an on_post_save or on_pre_save listener that is kicking off the build. I checked what I thought would be most likely (Mocha Runner) and it does have an on_post_save listener. I don't know if that's what you are seeing, but it would certainly explain it. Try disabling the plugins and rerunning the save to see if that is the case. If it is, you may want to create an issue on whatever plugin, asking them to make the "build on save" optional.

Related

Why does debug appear in the package.json file?

I just npm init in an empty folder that didn't do anything, but Debug is floating as shown in the picture.
Why is this floating?
Does this interfere with the error?
If it interferes, is there any way to get rid of it?
I would really appreciate it if you let me know.
This is not an error and the "debug" text is not actually part of the file.
VSCode inserts the "debug" button as a shortcut for running the scripts in the package.json file. When you click on it, a popup will appear allowing you to select the script you want to run or debug.

How to use file:duplicate from the palette using plugin in sublime text?

How to use File : duplicate option from the palette using plugin in sublime text ?
In order to see which command is being run when a particular action is being performed, open the console (Ctrl`) and run
sublime.log_commands(True)
Next, open the Command Palette (command: show_overlay {"overlay": "command_palette"} will show up in the console) and select File: Duplicate. The console will close, but when you reopen it you will see that command: side_bar_duplicate {} has been logged. At this point, you can enter
sublime.log_commands(False)
to stop logging, as it tends to fill the console with unnecessary garbage.
As you can see from the name of the command, File: Duplicate is from the SideBarEnhancements plugin (defined here) and is not built-in to Sublime. Therefore, if you are making a plugin for public distribution, you users will need to have SideBarEnhancements installed first.
To call this (or any) command in your plugin, simply put
window.run_command("side_bar_duplicate")
into your code at the appropriate location.
As #OdatNurd reminded me, because SideBarDuplicateCommand is a subclass of sublime_plugin.WindowCommand, it can only be run on an instance of sublime.Window.

How do I get npm to run in terminal?

I'm tasked with creating a simple calculator application for entry to a programming course. I'm having issues with Terminal :(
I'm not looking for an answer to my overall task, I just want to know why Terminal wont RUN!! What am I doing wrong?
Steps as follows:
Create a directory that you will keep your Calculator application in. Call it
something sensible, like "Calculator".
Open up a command prompt and navigate to your calculator directory
Run npm init to create a new Node.js project. Use the default answer to every
question it asks you (just press "Enter") - don't worry if you don't understand
what all the questions mean!
If it doesn't do anything after the final question "Is this ok?", double-check
there's a file in the folder called package.json . If it's there, everything went
smoothly and you can exit the npm init process by typing in the console
Ctrl + C .
So my problem is... when I run npm, all that happens is my Mac asks if Terminal can access or change files in my system, I click yes, then Terminal doesn't do anything from there, no questions etc I just get:
I can't see package.json, so I take it it hasn't worked properly? How can I fix this to move on?
I'm using zsh on terminal.
Well, first off. What ide do you use? (Personally I like Visual Studio Code).
I'm not sure what the short command is for you to open up the terminal but just google it. Otherwise, you can click "Terminal" on the very top and open a new terminal.
When you do this, you will get a new window at the bottom of your screen. This window has some tabs, make sure you are in the terminal tab.
While there, type "npm init".
This will give you your package.json-file.
If you want to use your terminal for outputs I recommend you get nodejs too.

Trying to get customization of Sublime Text 3 Build system to work

Does anyone know how automatic build systems work in 3083 right now? Because I am struggling to get it to do the right thing. (p.s. I am not an expert st3 customizer so I am probably just doing it wrong.)
My TypeScript.sublime-build file lives in ../Packages/User and contains:
{
"cmd": ["/usr/local/bin/tsc"],
"file_regex": "^(.+?) \\((\\d+),(\\d+)\\): (.+)$",
"selector": "source.TypeScript"
}
When I edit a .ts file the syntax highlighting is for TypeScript and that is also what is displayed in the bottom right corner. So from that I deduce that ST3 is correctly identifying the desired syntax for the file (although I am not sure where that happens.)
When I choose the TypeScript build system by hand and click CMD-B it runs the build and displays the output in the console, as I expected.
When I have "automatic" build system and I open a .ts file or change to a .ts file that was already open, ST3 again correctly identifies the syntax (bottom right in the window.) However when I click CMD-B it runs the last build method that I happened to have used.
I thought that the idea with automatic is that it would choose the build system based on the syntax identified via the file extension.
Does anyone understand this problem or correct my assumptions?
Never figured out the problem. But I fully uninstalled ST3 and reinstalled it, with the package control and typescript packages and nothing more, and now it seems to work. Oh well. I guess not all the bugs are out yet.

Sublime Text "Unable to save"

I didnt change any file paths and everything was working fine. I made one quick change saved it ok, did another change and I went to save it and got the following error. How can I solve this. It will save other files ok
Unable to save
D:\xampp\htdocs\websites\dev.liverpool\style\main.scss
Error:
MoveFileEx(D:\xampp\htdocs\websites\dev.liverpool\style\.sublae1.tmp, D:\xampp\htdocs\websites\dev.liverpoolzstylezmain.scss) failed,
Access is denied.
seems it's because Windows or another program is blocking the file. Sublime text uses a temporal file instead of editing the file directly, and when you save the file uses a API command to move this edited file to the original, so this command has restrictions when one file is locked and Sublime shows this alert.
Maybe this setting {"atomic_save": false} will work for you.
Go to the path where you installed sublime text 2 and...
Right click on the sublime_text 2.exe file.
Go to its properties.
Go to compatibility section under this.
Set its privilege level to "Run this program as an administrator".
Now change settings for all users and there also check the field "Run this program as an administrator".
Apply the changes.
I just solved the same issue on Sublime Text 3 beta, Stable Channel Build 3065 by doing the following under Windows 7:
Navigate to the Sublime Text 3 executable file, wherever you have it installed.
Right-click it and select properties.
Click on the tab marked "Security"
About half way down the tab, on the right hand side, under the list of group and user names is this little button:
Click it.
If your machine is setup the way I suspect it is (otherwise you probably would not be having this issue), you should be prompted for your administrator account credentials. Enter them.
Now, select the Users group in the list, then take a look in the box at the bottom labeled 'Permissions for Users'. Put a check mark in the 'Allow' column for the 'Write' item.
Click 'Apply'
Click 'OK'
You should be set. What this does is it essentially gives Sublime the ability to write files while running with regular user privileges, no administrator level access required. Upon taking a better look at your error, what is happening is Sublime Text is creating a temp file for editing, rather than editing to file itself, then attempting to overwrite the original file with the temp on save. The problem is that the program is not being run by a user with sufficient privileges to perform the overwrite, hence the failure with an 'Access denied' message.
A simple and effective solution: Right-click on the file you want to save, in my case it is index.html, go to the properties and uncheck read-only.
The Sublime text will start working fine.
I have come across this error quite many times and by un-checking read-only file attribute of index.html, I am able to get rid of it
I found out more ways to fix this:
Close and reopen the Sublime Text windows or
Open the file with Np++, add a space, save, quit, then you're prompted by ST to reload the file, click yes, and it works again... or
Open the FTP console to see if there's a transaction in progress - then cancel it
In my case the SFTP plugin seems to be causing this problem, as when the FTP connection is timed out, the file which is waiting to be uploaded is being used, and you try to overwrite it.
This happens because you're using ScoutApp or Compass, they block your SCSS files because they are checking for changes as you specified for a directory for those files.
I suggest you reading this:
http://aspirecode.com/how-to-add-sass-support-in-sublime-text/
Good luck!
On mac using a remote volume sometimes I experience this. The solution is to remove the temp file then save again and all fixed.
IE: if you are working on test.html then the temp file would be ._test.html
Remove ._test.html then save again.
For Mac-
Try changing the destination from 'Macintosh HD' to 'Documents' or any other folder.
Worked for me.
The plugin of Superlime solved this problem. It tries to save the file as root in SublimeText.
Reference Link: https://github.com/azubr/Superlime
Try switching your SublimeText process priority to higher level in process manager (it has to have higher priority than your scss compiling app, if you're using one).
It seems to have worked for me.
if it's not working after doing all suggestions, reinstall the program
On Mac I saved the file in Home directory and it gave me this alert, later when I re saved the file again this time in Document directory the file is working now. Using SublimeText 3.
I found this occurred when the folders are read-only. Right-click on the folders where your site is contained and see if read-only is selected in the properties.
Just open it as an administrator.
Because I want to edit anything and write as admin all the time, I set this program to always open as an administrator using "Configure Applications to Always Run as an Administrator".
Just got your file folder properties which you want to save and deselect to read only attribute.

Resources