Code Monkey home page Code Monkey logo

sublimetext-nodejs's Introduction

Nodejs Sublime Text 3 Package Build Status Build status

Overview

The Nodejs Sublime Text 3 Package provides a set of code completion, scripts and tools to work with nodejs.

Code Completion

The package code completion is generated from the main nodejs libraries and global namespaces. To invoke the code completion start typing the namespace you want (For example, type fs) and then Ctrl + Space, you get this:

A picture of the file system context menu

Node Commands

You can access node commands in two ways.

  • Via the menu in Tools -> Node
  • By accessing the Command Palette and typing node

The current commands available are (with Windows binding, other bindings are provided):

  • Run current script in node (Alt + R)
  • Run current script in node debug (Alt + D)
  • Run current script in node and arguments (Ctrl + Alt + r)
  • Run current script in node debug and arguments (Ctrl + Alt + D)
  • Uglify Code
  • NPM Command
  • Build documentation (builds the completion files)

Snippets

Also included are some boilerplate snippets. They include functionality such as a http server, reading the contents of a directory, etc.

To access these snippets type node in your editor followed by Ctrl + Space

If you have any boilerplate code you would like to see in here, get in touch.

Install

You can install this package from Sublime Text 3 package manager. Also you can install this package manually:

MacOSX

`git clone https://github.com/tanepiper/SublimeText-Nodejs.git ~/Library/Application\ Support/Sublime\ Text\ 3/Packages/Nodejs`

Windows

`git clone https://github.com/tanepiper/SublimeText-Nodejs "%APPDATA%\Sublime Text 3\Packages\Nodejs"`

Linux

`git clone https://github.com/tanepiper/SublimeText-Nodejs $HOME/.config/sublime-text-3/Packages/Nodejs`

After the package is installed, install Node.js packages needed for working the package built-in tools. You can to install either globaly by: npm install -g commander@"~2.9.0" uglify-js@"~2.6.0" or localy by adding previously mentioned Node.js packages to your current project, either: npm install commander@"~2.9.0" uglify-js@"~2.6.0" or manully editing your project package.json file.

PLEASE NOTE: When your installed Node.js packages (previously mentioned) globaly, you also need to set the package node_path setting. For that, go to the Preferences -> Package Settings -> Nodejs -> Settings User.

Build Systems

PLEASE NOTE: The build system will be refactored to provide different nodejs build systems (such as jake)

If you have a JavaScript file open, by selecting Tools -> Build Systems -> Nodejs and then hitting Ctrl + B, you will activate the node build system on your file and node will try to run it. You may need to add a path variable to the settings object for this if your node executable is not found

TODO

  • uglify_js.js and other ./tools/*.js scripts dosen't work when the package is installed by SublimeText package manager
  • Use events API to install NodeJs dependicies for tools provided by the package
  • Refactor plugin's classes inheritance in Nodejs.py
  • Use events API to generate Sublime Text completions during installation phase depending on a version of installed NodeJs
  • Check for nvm installation
  • Replace the Nodejs.sublime-build to work with jake
  • Reorganise menu structure
  • Improve code completion snippets where possible
  • Provide an interface for writing JavaScript plugins

Author & Contributors

The original author of this package Tane Piper. At the time the project maintainer is Vardan Pogosian.

sublimetext-nodejs's People

Contributors

aaronpowell avatar alexocode avatar andreslozadamosto avatar artfeel avatar chovin avatar ericmcornelius avatar fake-or-dead avatar fredericosilva avatar gryor avatar krausestefan avatar mamong avatar mrowen avatar ptrm avatar rishihahs avatar safareli avatar sinabs avatar skalinets avatar tanepiper avatar varp avatar vfrbgt avatar y-lan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sublimetext-nodejs's Issues

Certain completions not appearing

Certain completions do not show up in the popup box, in particular, console.log from the Nodejs.sublime-completions file. Not sure what could be interfering with it, any suggestions on tracking it down? Seems most of the other ones do complete based on a random sampling of them.

image

File name is requests-test.js and Sublime syntax is JavaScript Next.

{
  "trigger": "console.log();",
  "contents": "log();$0"
},

Conflict with native JS autocomplete

Great job on the package. One issue though: There seems to be a conflict with native JS autocomplete when I install nodejs module. If i declare a variable, it doesn't always appear in the autocomplete after

var varName = 12312;

try then mentioning varName in your code. Sometimes it will appear in autocomplete (varName variable), but most of the times not. If I uninstall Nodejs package, variables will always be autocompleted.

new error message from Nodejs

I don't remember adding or changing anything, but I'm now getting the following error when I open any document/file and Nodejs is enabled.

[Errno 2] No such file or directory: 'npm'
[cmd: ['npm', 'install', '-s']]
[dir: /home/landis/.config/sublime-text-3/Packages/Nodejs]
[path: /home/landis/bin:/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games:/usr/lib64:/home/landis/.local:/home/landis/.local/share/icons:/usr/lib64:/home/landis/.local:/home/landis/.local/share/icons]

I want to, don't know how to 'Force' re-install it through package-control.
I don't want to 'remove' and re-install it with package-control, because I don't know how packages are 'hooked' to other packages that depend on it in Sublime-Text3.
eg, HTML/CSS/jscript-prettify among others.
If Nodejs is called by other packages, it should be ok, like packages calling clib in Linux, but if they have hooks re-written the first time they were installed with versioning details, they will fail.

Landis.

p.s - Nodejs package.json

{
"name": "sublime-nodejs",
"version": "1.5.6",
"description": "NPM Support file for the Sublime Text 3 Nodejs Plugin",
"dependencies": {
"commander": "^2.9.0",
"uglify-js": "^2.6.4",
"tern": "^0.21.0"
}
}
EDIT
Just remembered. A week ago, when I started Sublime Text, a message said a 'Dependency was installed, restart ST3'. I wasted an hour trying to figure out What was installed and then gave up, assuming all was ok.. Not so, because I started getting the Nodejs NPM directory/file errors. I disabled Nodejs and now I want it back.

how to run command "node-dev"

I want replace the command "node" to "node-dev" when "Ctrl + R"

try modify "Nodejs.sublime-settings":

"node_command": "/usr/local/bin/node-dev",

but it not work..

Stop running script

Once a script is running it can be hard to kill, it'd be good if there was a command that could be used to kill the running script

Typo in http.createServer snippet

var http = require('http');
var server = http.createServer(function(req, res) {
res.send('Hello World');
});
server.listen(9000);

should be

res.end(...)

LookupError: unknown encoding

example.js;

var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello World\n');
}).listen(1337, "127.0.0.1");
console.log('Server running at http://127.0.0.1:1337/');

alt+r ( alt+d also)

gives this in sublime console;

Exception in thread Thread-1:
Traceback (most recent call last):
File ".\threading.py", line 532, in __bootstrap_inner
File ".\lib\command_thread.py", line 44, in run
File ".\lib\command_thread.py", line 20, in _make_text_safeish
LookupError: unknown encoding:

its utf8 on the file, windows 64bit, sublime 2165

shell_cmd": "taskkill /F /IM node.exe & node $file not working with Sublime Text 3 on Windows 7

The line in sublime-build "shell_cmd": "taskkill /F /IM node.exe & node $file" is causing an error ERROR: The process "node.exe" not found..

If I comment out the taskkill line the error disappears.

I've added "node_command": "C:\\Program Files\\nodejs\\node.exe" in user sublime-settings.

How can I fix this??

{
  "cmd": ["node", "$file"],
  "file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
  "selector": "source.js",
  "shell": true,
  "encoding": "cp1252",
  "windows":
    {
        "shell_cmd": "taskkill /F /IM node.exe & node $file"
    },
    "linux":
    {
        "shell_cmd": "killall node; /usr/bin/env node $file"
    },
    "osx":
    {
        "shell_cmd": "killall node; /usr/bin/env node $file"
    }
}

warning: mnemonic t not found in menu caption Tools

getting warning: mnemonic t not found in menu caption Tools spammed in the console in ST3.

Not quite sure what this is referring to but upon changing it to "mnemonic": "T" in Main.sublime-menu the spam stops.

'is_enabled must return a bool'

I'm setting up Sublime Text for the first time to start Node.js development and I can't get your nodejs plugin to run node.

I am running Sublime Text 3 "Stable Channel, Build 3047" and I installed the Nodejs package using Package Control.

Whenever I attempt to run my Node.js project (or even open the context menu I get the following on my console:

Traceback (most recent call last):
  File "C:\Program Files\Sublime Text 3\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.NodeRunCommand object at 0x00000000036B3748>)
Traceback (most recent call last):
  File "C:\Program Files\Sublime Text 3\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.NodeRunCommand object at 0x00000000036B3748>)
Traceback (most recent call last):
  File "C:\Program Files\Sublime Text 3\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.NodeRunArgumentsCommand object at 0x00000000036B3400>)
Traceback (most recent call last):
  File "C:\Program Files\Sublime Text 3\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.NodeRunArgumentsCommand object at 0x00000000036B3400>)
Traceback (most recent call last):
  File "C:\Program Files\Sublime Text 3\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.NodeDrunCommand object at 0x00000000036B34E0>)
Traceback (most recent call last):
  File "C:\Program Files\Sublime Text 3\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.NodeDrunCommand object at 0x00000000036B34E0>)
Traceback (most recent call last):
  File "C:\Program Files\Sublime Text 3\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.NodeDrunArgumentsCommand object at 0x00000000036B3AC8>)
Traceback (most recent call last):
  File "C:\Program Files\Sublime Text 3\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.NodeDrunArgumentsCommand object at 0x00000000036B3AC8>)

If someone could let me know what I have done wrong in the set up or how to work around this issue it would be much appreciated.

Thank you.

can not run

I got this error

Node binary could not be found in PATH

Consider using the node_command setting for the Node plugin

PATH is: /usr/bin:/bin:/usr/sbin:/sbin

Turning off shortcuts

Hi,

Could I ask how I can turn off shortcuts, specifically NodeJS > Debug [^ + D]? The NodeJS shortcuts are interfering with VI mode for me

Thanks!
Nolan

screen shot 2017-05-05 at 12 45 09 pm

code completion across files

Hey,
I have the question whether it is possible to get all the methods put into the module.export by modules you required

Like:
You are editing file a which requires fileb like
var saver = require('fileb');
in fileb you defined something like
module.export.save = function(item){ ... stuff; ...}
and then you could say saver. and there apears the autocompletion for the save function

Update to latest Commander?

Get rid of the npm warn message when installing dependencies.

This sublime package requires Commander 0.3.3 which in turn requires a node version < 0.7.0. Seeing as node stable is now 0.8.9, I don't see a problem using the latest Commander which does support the latest node stable and dev versions. Travis says Commander has been failing tests since 0.5.1 but there's only tests for node 0.5 and 0.6 (http://travis-ci.org/#!/visionmedia/commander.js/builds) so that's the only reservation because the latest Commander doesn't seem to have deprecated anything the sublime package uses.

UglifyJS -> Unexpected token: operator (>)

I installed this package via the package manager and then I tried to run the UglifyJS on my .js file and got this error:

undefined:1625

    throw new JS_Parse_Error(message, filename, line, col, pos);

    ^

SyntaxError: Unexpected token: operator (>)

Caused by this:

things.forEach(entry => {
});

Problem with auto completion

The 'auto completion' is not 'to complete', but to replace. If I type 'fs', then the suggestion is 'fs.close()', I hit tab(or any other key I set), the result will be 'close()', not 'fs.close()'.

sublime version: v3 3143 (x64)

And it makes Javascript completion plugin can not auto-complete, I am not sure whether this is nodejs's problem or that plugin's.

NODE_PATH not being considered

I have NODE_PATH defined as

export NODE_PATH="/Users/usename/Dropbox/Mackup/lib/node_modules"

where

node
> require('request')

works fine on Terminal,
but when it comes to SublimeText-Nodejs it won't load any module I have installed, looking only for modules installed where the document is saved.

How can I use global NPM modules?

Thanks in advance

JSON autocomplete ?

There is no autocomplete for JSON.stringify ?

JSON.
Then press Ctrl+Space....

Nothing there.

I'm missing something?

Debugger?

I want to bump the issue #12 since the creator answered but he no longer works on this project, and then closed the issue.

The debugger also uses node debug, which is deprecated. node inspect is supposed to be used instead.

Spaces in path causes "Error: cannot find module"

If you try to build a file which has a space in the path to the file this causes an error. Only tested on Windows. In my case the error is:

Error: Cannot find module 'F:\Dropbox'
    at Function.Module._resolveFilename (module.js:555:15)
    at Function.Module._load (module.js:482:25)
    at Function.Module.runMain (module.js:701:10)
    at startup (bootstrap_node.js:193:16)
    at bootstrap_node.js:617:3

The filepath in this case being: "F:\Dropbox (Personal)\[...]\main.js"

I fixed the issue for myself by changing Nodejs.sublime-build to:

    "shell_cmd": "taskkill /F /IM node.exe & node \"$file\""

How do I set a custom node path?

I'm getting an error when ever I try to use a utility from the Tools --> NodeJS menu:

Node binary could not be found in PATH

Consider using the node_command setting for the Node plugin

PATH is: /usr/bin:/bin:/usr/sbin:/sbin

I ran which node in terminal and got /usr/local/bin/node. How do I set that as the default node path?

Add common npm commands

Can some of the common npm commands be added to the command palette, like:

  • Install
  • Update
  • Uninstall

ImportError: No module named command_thread

On Sublime Text 2.0.2 (Windows 7), I always get the following error message in the Sublime Text console whenever Sublime Text is started. Uninstalling and reinstalling the package did not solve the problem.

Reloading plugin C:\Users\insrkum\AppData\Roaming\Sublime Text 2\Packages\Nodejs\Nodejs.py
Traceback (most recent call last):
File ".\sublime_plugin.py", line 62, in reload_plugin
m = imp.load_module(modulename, *m_info)
File ".\Nodejs.py", line 6, in
from lib.command_thread import CommandThread
ImportError: No module named command_thread
Reloading plugin C:\Users\insrkum\AppData\Roaming\Sublime Text 2\Packages\Nodejs__init__.py
Traceback (most recent call last):
File ".\sublime_plugin.py", line 62, in reload_plugin
m = imp.load_module(modulename, *m_info)
File ".init.py", line 1, in
from Nodejs import *
File ".\Nodejs.py", line 6, in
from lib.command_thread import CommandThread
ImportError: No module named command_thread
Reloading plugin C:\Users\insrkum\AppData\Roaming\Sublime Text 2\Packages\Package Control\Package Control.py

Autocompletion duplicates root object

If I start to type an object and method in JS, say

screen shot 2017-03-30 at 2 39 05 pm

and then hit tab, the root object is duplicated in the autocomplete, eg.

http.http.createServer(requestListener);

Node path

node

Where to add node path (win-10 ) in sublime package setting.

Error loading modules

The plugin seems to have a problem loading modules. I have several installed with npm -g in /usr/local/lib/node_modules and have setup my NODE_PATH as well but when I Ctrl+B in slt2 it says it can't find the module. Anyone else experience this?

package.json : Finished with exit code 1

Hi, command can not run in package.json script mode.
how to config it in Nodejs.sublime-build
or use other tools such as "commander".

and "Ctrl-B" bind with root command "npm run dev" or "yarn start" ?

besides, how to run in debug mode with break point?

thanx~

Decode error - output not cp1252

My System is Ubuntu 10.04. When I use Ctrl + B to build, I always got 'Decode error - output not cp1252'. I already changed the build system to 'Nodejs'.

Nodejs.sublime-settings edited as follow:
{
// 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/bin/node",
// Same for NPM command
"npm_command": "/usr/bin/npm",

"expert_mode": true,

"ouput_to_new_tab": false
}

I also added "encoding": "uft-8" or "cp1252" or "UTF-8" or "uft8". I also googled, but only found 'Decode error - output not utf-8'. It's not the same.

Please help.

console.log messages do not appear in the output panel

I've installed the plugin and attempted to run some scripts. No idea if they work because they don't output anything in the output panel. Perhaps I'm doing something wrong, but it should be far more obvious what that is.

UnicodeDecodeError: 'gbk' codec can't decode byte 0xa6 in position 325: illegal multibyte sequence

hello , i got a problem when i am used to npm module , i need help , thanks very much! os:window 10 version:1607 sublime version: build 3126

when i have running every npm command , i always get below exception

Exception in thread Thread-942:
Traceback (most recent call last):
File "./python3.3/threading.py", line 901, in _bootstrap_inner
File "C:\Users\shuangmin\AppData\Roaming\Sublime Text 3\Packages\Nodejs\Nodejs.py", line 29, in run
output = p.communicate()[0]
File "./python3.3/subprocess.py", line 907, in communicate
File "./python3.3/subprocess.py", line 479, in _eintr_retry_call
UnicodeDecodeError: 'gbk' codec can't decode byte 0xa6 in position 325: illegal multibyte sequence

Error when run Nodejs package tools installed by package_manager

Traceback (most recent call last):
File "/Applications/Sublime Text.app/Contents/MacOS/sublime_plugin.py", line 818, in run_
return self.run(edit)
File "Nodejs in /Users/vardanpro/Library/Application Support/Sublime Text 3/Installed Packages/Nodejs.sublime-package", line 369, in run
File "Nodejs in /Users/vardanpro/Library/Application Support/Sublime Text 3/Installed Packages/Nodejs.sublime-package", line 68, in run_command
File "Nodejs in /Users/vardanpro/Library/Application Support/Sublime Text 3/Installed Packages/Nodejs.sublime-package", line 172, in get_working_dir
File "./python3.3/posixpath.py", line 151, in dirname
AttributeError: 'NoneType' object has no attribute 'rfind'

Uglify error

Hi,

I am very excited about your plugin. However I am facing an error when trying to uglify the code:

node.js:201
        throw e; // process.nextTick error, or 'error' event on first tick
              ^
Error: Cannot find module 'commander'
    at Function._resolveFilename (module.js:332:11)
    at Function._load (module.js:279:25)
    at Module.require (module.js:354:17)
    at require (module.js:370:17)
    at Object.<anonymous> (C:\Users\Master\AppData\Roaming\Sublime Text 2\Packages\Nodejs\tools\uglify_js.js:1:79)
    at Module._compile (module.js:441:26)
    at Object..js (module.js:459:10)
    at Module.load (module.js:348:31)
    at Function._load (module.js:308:12)
    at Array.0 (module.js:479:10)

What am I missing? Shoud I have installed any node package?

Thanks!!

setImmediate() and node apis version

Why isn't there setImmediate()? how can i add this? also, how can i use some specific apis like i want to use api for 0.9.12 how can i achieve this? thanks in advance

How to use the build system?

The Build Systems section doesn't really help nodejs beginners.

If you have a JavaScript file open, by selecting selecting Tools -> Build Systems -> Nodejs and then hitting Ctrl + B, you will activate the node build system on your file and node will try to run it. You may need to add a path variable to the settings object for this if your node executable is not found.

Nodejs.sublime-settings:

{
    "path": "/home/leme/workspaces/mynode"
}

When hitting Ctrl + B:

node: no process found
[Finished in 0.1s]

Could you add some more notes on how to configure the build system correctly?

Coffeescript support

I'm using the following package with ST2 for coffeescript support:
https://github.com/jashkenas/coffee-script-tmbundle

I've installed SublimeText-Nodejs and get code completion when editing *.js files. But when editing *.coffee files, I don't. Is this something that could be easily added? It seems like it would be.

I don't mind making the changes and submitting a pull request, but I'm looking for advice. I've never worked with textmate/sublime packages before.

Build system kills nodemon

Hello,

I'm using nodemon for development since I don't want to restart my node apps every time I do a modification to a file.

It seems like I cannot use the build system to launch a node script that would connect to a deamon running with nodemon. Nodemon just exists saying it was killed.

Any way around this? I'd really love to not have to have a seperate prompt for running my script and do it all in sublime text.

Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.