Code Monkey home page Code Monkey logo

sublime-import-js's Introduction

ImportJS is a tool that helps you import dependencies in your JavaScript project. More information is available in the main import-js project.

Running import-js in Sublime Text

  1. Install the ImportJS plugin via Package Control

  2. Install the import-js npm package

    npm install -g import-js
  3. Configure import-js

  4. Open the root of your project as a folder (Project -> Add Folder to Project…)

  5. Import a file!

    Whenever you have undefined variables, open the Command Palette (CTRL+SHIFT+P/CMD+SHIFT+P) and select "ImportJS: fix all imports", or "ImportJS: import word under cursor".

It will be helpful to bind import_js to easy-to-use bindings, such as:

{ "keys": ["super+alt+i"], "command": "import_js", "args": { "command": "fix" } },
{ "keys": ["super+alt+j"], "command": "import_js", "args": { "command": "word" } },
{ "keys": ["super+alt+g"], "command": "import_js", "args": { "command": "goto" } },

Available commands:

  • "ImportJS: fix all imports"
  • "ImportJS: import word under cursor"
  • "ImportJS: goto module"
  • "ImportJS: terminate daemon"

Troubleshooting

If you get an error message saying something like "Can't find import-js executable", you may need to specify a path to the importjs executable in configuration. This likely means that you are using a tool like nvm or nodenv to manage multiple Node versions on your system.

To fix this, you need to make sure that the code that sets up your PATH is in the correct location. This plugin will open a login shell to determine the proper PATH, so the code that sets up your PATH needs to be in a file that is sourced for login shells. Here's a handy table:

Shell File
bash ~/.bash_profile
zsh (Mac OS X) ~/.zprofile
zsh (Linux) ~/.zshenv or ~/.zprofile
fish ~/.config/fish/config.fish

Alternatively, you can also try editing the ImportJS User Settings from the Preferences > Package Settings > ImportJS > Settings — User menu and add the folder where the importjs executable is located to the paths option. Example:

{
  "paths": ["/Users/USERNAME/.nvm/versions/node/v4.4.3/bin"]
}

Please note that you can't use ~ to refer to the home directory, you need to specify the full path. To figure out where your importjs executable is located, you can run which importjs from your project's directory.

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.