Nodejs fails in sublime - node.js

I have installed sublime2, package control module and nodejs through it.
After opening my js application I am getting next error, when try to run my application Tools->NodeJS->Run.
File "/Applications/Sublime Text.app/Contents/MacOS/sublime_plugin.py", line 445, in is_enabled_
raise ValueError("is_enabled must return a bool", self)
ValueError: ('is_enabled must return a bool', <Nodejs.Nodejs.NodeUglifyCommand object at 0x10f70bc90>)
All items in the menu are disabled.
Also I have tried modify user settings use next one:
{
// 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": "/usr/local/Cellar/node/0.10.25",
"expert_mode": false,
"ouput_to_new_tab": false
}
I have installed node via brew.

I had the same problem with my custom build system. The solution is just to choose the build system you want to use.
There must be checkmark alongside some build system in Tools->Build System

Related

How to write a file using LF instead of CRLF on Windows?

We have a script that runs as the preinstall script. It uses fs.writeFile to write a config file which it generates.
writeFile(configFilePath, configFileContents, (e) => {
// ... do some error handling
}
For some reason it uses CRLF line endings on Windows and creating diffs in git although the file has not changed.
I have tried to do use
.replace(/\r\n/gm, "\n");
on configFileContents but it still uses the Windows line endings.
configFileContents gets created by:
const configFileContents = JSON.stringify({
foo: bar,
baz, foo,
// ...
}, null, 2);
Is there a way to tell Node to use the Linux ones?
You can simply do this:
.replace(/\r\n/g, "\n")
Also /\r\n/gm regexp isn't correct as you're already telling the Regexp engine to look for new line by providing the m/multiple lines option... That's why it doesn't allow the expression to work. Just use g if you really wan't to use the RegExp
I used prettier to update the file automatically after the file was created, that worked for me. So i just added prettier command in extention to the file creation npm script.
prettier \"supportedBrowsers.ts\" --write"

Using node-cmd module while handling Squirrel Events function

I'm building a desktop app for Windows using electron-packager and electron-squirrel-startup, I would like to execute some Windows cmd commands during the installation of my application. To do so I was planning to use node-cmd node module, but I doesn't really work inside the handleSquirrelEvents function. An example command like this:
function handleSquirrelEvent(application) {
const squirrelEvent = process.argv[1];
switch (squirrelEvent) {
case '--squirrel-install':
case '--squirrel-updated':
var cmd=require('node-cmd');
cmd.run('touch example.created.file');
}
};
Seems to work. A file example.created.file in my_app/node_module/node-cmd/example directory is created.
But any other code does not work. Even if I only change the name of the file to be "touched" nothing happens.
Ok, example.created.file already exists in this directory and I suspect that you can only use update.exe supported commands in case '--squirrel-updated' sections. So this will not work.

sublime text 3 package control install

I have a problem when I install the package control of sublime text 3 because of the proxy set but I need to install a plugin. When I do getproxy in the console it returns me {} and when I try to set the proxy with python in console with
urllib.set_proxy('http://user:password#server:port', 'http')
I replaced the user, password, server and port by their values but it returns me
Traceback (most recent call last):
File "<string>", line 1, in <module>
AttributeError: 'module' object has no attribute 'set_proxy'
what can I do to make it work? I need to install a plugin .
Setting Up Package Control to Work from Behind a Proxy Server
You will need to setup your proxy server in the Package Control settings.
Copy and paste the code below into a file called Package Control.sublime-settings which must be saved in your User config folder. That is the same folder as your USER Preferences.sublime-settings file is saved in. The Data Directory states where this is on your operating system. i.e.
Windows: %APPDATA%\Sublime Text 3\Packages\User\Package Control.sublime-settings
OS X: ~/Library/Application Support/Sublime Text 3/Packages/User/Package Control.sublime-settings
Linux: ~/.config/sublime-text-3/Packages/User/Package Control.sublime-settings
Clearly you must add the domain and port and your user name and password in the relevant fields below. The proxy should be in the form: proxyserver:port. e.g.
{
"http_proxy": "server.com:80",
"https_proxy": "server.com:8080",
"proxy_username": "mynameis",
"proxy_password": "mypassis",
}
See also: Package Control Settings
{
// An HTTP proxy server to use for requests. Not normally used on Windows
// since the system proxy configuration is utilized via WinINet. However,
// if WinINet is not working properly, this will be used by the Urllib
// downloader, which acts as a fallback.
"http_proxy": "",
// An HTTPS proxy server to use for requests - this will inherit from
// http_proxy if it is set to "" or null and http_proxy has a value. You
// can set this to false to prevent inheriting from http_proxy. Not
// normally used on Windows since the system proxy configuration is
// utilized via WinINet. However, if WinINet is not working properly, this
// will be used by the Urllib downloader, which acts as a fallback.
"https_proxy": "",
// Username and password for both http_proxy and https_proxy. May be used
// with WinINet to set credentials for system-level proxy config.
"proxy_username": "",
"proxy_password": "",
}
You could simply run the below command in the Sublime 3 console (launch console using CTRL+` or View -> Show Console)
import urllib.request,os; pf = 'Package Control.sublime-package'; ipp = sublime.installed_packages_path(); urllib.request.install_opener( urllib.request.build_opener( urllib.request.ProxyHandler({'http': 'http://USER:PASSWORD#HOST:PORT', 'https': 'https://USER:PASSWORD#HOST:PORT'})) ); open(os.path.join(ipp, pf), 'wb').write(urllib.request.urlopen( 'http://sublime.wbond.net/' + pf.replace(' ','%20')).read())
In the above code, you need to replace the value(USER:PASSWORD#HOST:PORT) of http and https keys as per your proxy details
Then hit Enter and it will install the Package Control using the provided proxy
I exactly had the same issue, I was unable to download packages for Sublime Text 3. I set up the proxy server at runtime as shown in below snippet in the Sublime console (Mac Shortcut Ctrl + `) and it worked for me.
import os
proxy_server = 'http://username:password#proxy_server_name:port'
os.environ['http_proxy'] = proxy_server
os.environ['HTTP_PROXY'] = proxy_server
os.environ['https_proxy'] = proxy_server
os.environ['HTTPS_PROXY'] = proxy_server
os.environ['all_proxy'] = proxy_server
os.environ['ALL_PROXY'] = proxy_server
os.environ['ftp_proxy'] = proxy_server
os.environ['FTP_PROXY'] = proxy_server
for socks5 proxy settings:
menubar: Preferences > Package Settings > Package Control > Settings
NOTE: curl downloadder backend support socks5.
{
"downloader_precedence": {
"linux": ["curl"]
},
"http_proxy": "socks5://127.0.0.1:1080",
"proxy_password": "",
"proxy_username": "",
...

Execute URL/Path in external program in Haxe

It is possible to run URL or path with external program from Haxe?
Something like a Process.Start("C:\") in C# will be opened drive C in file windows explorer (or Process.Start("/home/user/Desktop") will open Caja with this path in Linux Mint), or somethink like a package "Open" in NodeJS (it will do the same).
Or I need to open some text file with text editor, what selected in system by default.
Or when I try to run URL, then must be opened default web-browser with this address.
I think I can do this little code:
public static function execUrl (url:String) : Void {
switch (Sys.systemName()) {
case "Linux", "BSD": Sys.command("xdg-open", [url]);
case "Mac": Sys.command("open", [url]);
case "Windows": Sys.command("start", [url]);
default:
}
}
in unix-like systems can be used program "xdg-open". it know how to run needed path/url, and in windows this can do program "start"

How to create a JSCS config file on windows

When I try to create a JSCS config file:
C:\Blog\BlogWeb>jscs --auto-configure "C:\Blog\BlogWeb\temp.jscs"
I get the following error:
safeContextKeyword option requires string or array value
What parameter am I supposed to pass? What is a safecontextkeyword?
New to NPM and JSCS, please excuse ignorance.
JSCS was complaining that I didn't have a config file, so I was trying to figure out how to create one.
JSCS looks for a config file in these places, unless you manually specify it with the --config option:
jscs it will consequentially search for jscsConfig option in package.json file then for .jscsrc (which is a just JSON with comments) and .jscs.json files in the current working directory then in nearest ancestor until it hits the system root.
I fixed this by:
Create a new file named .jscsrc. Windows Explorer may not let you do this, so may need to use the command line.
Copy the following into it. It doesn't matter if this is the preset you want to use or not. The command will overwrite it.
{
"preset": "jquery",
"requireCurlyBraces": null // or false
}
Verify that it works by running a command such as:
run the command
jscs --auto-configure .jscsrc

Resources