SublimeLinter: NVM: cannot locate 'eslint' / 'node' etc

After recent update, Sublime always popup the tips:

SublimeLinter: WARNING: eslint cannot locate 'eslint'.

In detail:

I haven’t install global eslint, because I have to extend the eslint rules in config file in projects, If using the global eslint, the xxx-eslint-config package is not used.

When the project is configed properly, and with local eslint installed, everything works very well.

But if I open a file not in project (in a single window), there always a popup tips in the sublime console.

In previous versions (not sure which version), no such problem.

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 1
  • Comments: 61 (24 by maintainers)

Most upvoted comments

@TooBug

I was seeing the env: node: No such file or directory error as well.

I’m on OSX. I had recently uninstalled node with brew, which means it was no longer at /usr/local/bin/node. I installed a previous version of node with brew: running which node returned /usr/local/opt/node@8/bin/node.

I figured Sublime Linter didn’t know about this node executable, even though it’s in my $PATH, so I just symlinked it to /usr/local/bin by running ln -s /usr/local/opt/node@8/bin/node /usr/local/bin/node. After that Sublime Linter could find node again and the error went away.

@braver @kaste On OSX, I can confirm that adding the following to Sublime Linter’s settings does not solve the problem.

"paths": {
    "osx": ["/usr/local/opt/node@8/bin"],
},

However, the fix suggested here does solve the problem. In other words, adding this works:

"linters": {
  "eslint": {
      "env": {"PATH": "/usr/local/opt/node@8/bin"}
  }
}

I don’t know how Sublime Linter resolves paths, but it seems that if SublimeLinter-eslint can be fixed by adding a PATH to its env setting which is already in the user’s $PATH, then SublimeLinter-eslint should be able to pull in the user’s $PATH and not require the user to change anything in his settings.

I figured it out. It’s because i’m using NVM, so I had to add the correct executable path in SublimeLinter’s settings

"paths": {
		"osx": ["~/.nvm/versions/node/v9.5.0/bin"]
	}

Same problem, new version installed automatically and everything is now broken.

@braver I’ve viewed similar issues, but seems no one describes my situation.

IN PROJECT:

working, but has a tips says env: node: No such file or directory

image

startup, version: 3143 osx x64 channel: stable
executable: /Applications/Sublime Text.app/Contents/MacOS/Sublime Text
working dir: /
packages path: /Users/TooBug/Library/Application Support/Sublime Text 3/Packages
state path: /Users/TooBug/Library/Application Support/Sublime Text 3/Local
zip path: /Applications/Sublime Text.app/Contents/MacOS/Packages
zip path: /Users/TooBug/Library/Application Support/Sublime Text 3/Installed Packages
ignored_packages: ["Vintage"]
pre session restore time: 0.505736
startup time: 0.563202
reloading plugin Default.auto_indent_tag
reloading plugin Default.block
reloading plugin Default.comment
reloading plugin Default.convert_syntax
reloading plugin Default.copy_path
reloading plugin Default.delete_word
reloading plugin Default.detect_indentation
reloading plugin Default.duplicate_line
reloading plugin Default.echo
reloading plugin Default.exec
reloading plugin Default.fold
reloading plugin Default.font
reloading plugin Default.goto_line
reloading plugin Default.history_list
reloading plugin Default.indentation
reloading plugin Default.install_package_control
reloading plugin Default.kill_ring
reloading plugin Default.mark
reloading plugin Default.new_templates
reloading plugin Default.open_context_url
reloading plugin Default.open_in_browser
reloading plugin Default.pane
reloading plugin Default.paragraph
reloading plugin Default.paste_from_history
reloading plugin Default.profile
reloading plugin Default.quick_panel
reloading plugin Default.run_syntax_tests
reloading plugin Default.save_on_focus_lost
reloading plugin Default.scroll
reloading plugin Default.set_unsaved_view_name
reloading plugin Default.settings
reloading plugin Default.show_scope_name
reloading plugin Default.side_bar
reloading plugin Default.sort
reloading plugin Default.swap_line
reloading plugin Default.switch_file
reloading plugin Default.symbol
reloading plugin Default.transform
reloading plugin Default.transpose
reloading plugin Default.trim_trailing_white_space
reloading plugin Default.ui
reloading plugin CSS.css_completions
reloading plugin Diff.diff
reloading plugin HTML.encode_html_entities
reloading plugin HTML.html_completions
reloading plugin 0_package_control_loader.00-package_control
reloading plugin 0_package_control_loader.01-pygments
reloading plugin 0_package_control_loader.50-dateutil
reloading plugin 0_package_control_loader.50-markupsafe
reloading plugin 0_package_control_loader.50-python-markdown
reloading plugin 0_package_control_loader.51-python-jinja2
reloading plugin 0_package_control_loader.55-jsonschema
reloading plugin 0_package_control_loader.55-mdpopups
reloading plugin DocBlockr.jsdocs
reloading plugin EditorConfig.EditorConfig
reloading plugin GhostText.FocusSublimeWindow
reloading plugin GhostText.GhostText
reloading plugin Local History.LocalHistory
reloading plugin Material Theme.Icons
reloading plugin Material Theme.MT
Traceback (most recent call last):
  File "/Applications/Sublime Text.app/Contents/MacOS/sublime_plugin.py", line 109, in reload_plugin
    m = importlib.import_module(modulename)
  File "./python3.3/importlib/__init__.py", line 90, in import_module
  File "<frozen importlib._bootstrap>", line 1584, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1565, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1532, in _find_and_load_unlocked
  File "/Applications/Sublime Text.app/Contents/MacOS/sublime_plugin.py", line 915, in load_module
    exec(compile(source, source_path, 'exec'), mod.__dict__)
  File "MT in /Users/TooBug/Library/Application Support/Sublime Text 3/Installed Packages/Material Theme.sublime-package", line 1, in <module>
  File "/Applications/Sublime Text.app/Contents/MacOS/sublime_plugin.py", line 915, in load_module
    exec(compile(source, source_path, 'exec'), mod.__dict__)
  File "utils in /Users/TooBug/Library/Application Support/Sublime Text 3/Installed Packages/Material Theme.sublime-package", line 3, in <module>
  File "/Applications/Sublime Text.app/Contents/MacOS/sublime_plugin.py", line 915, in load_module
    exec(compile(source, source_path, 'exec'), mod.__dict__)
  File "utils.config in /Users/TooBug/Library/Application Support/Sublime Text 3/Installed Packages/Material Theme.sublime-package", line 8, in <module>
  File "/Users/TooBug/Library/Application Support/Sublime Text 3/Packages/mdpopups/st3/mdpopups/__init__.py", line 27, in <module>
    from . import frontmatter
  File "/Users/TooBug/Library/Application Support/Sublime Text 3/Packages/mdpopups/st3/mdpopups/frontmatter.py", line 2, in <module>
    import yaml
ImportError: No module named 'yaml'
reloading plugin Package Control.1_reloader
reloading plugin Package Control.2_bootstrap
reloading plugin Package Control.Package Control
reloading plugin PHP Completions Kit.plugin
reloading plugin SublimeGit.SublimeGit
reloading plugin SublimeLinter-eslint.linter
reloading plugin SublimeLinter.__init__
reloading plugin SublimeLinter.busy_indicator_view
reloading plugin SublimeLinter.commands
reloading plugin SublimeLinter.goto_commands
reloading plugin SublimeLinter.highlight_view
reloading plugin SublimeLinter.log_handler
reloading plugin SublimeLinter.message_view
reloading plugin SublimeLinter.panel_view
reloading plugin SublimeLinter.status_bar_view
reloading plugin SublimeLinter.sublime_linter
reloading plugin SublimeLinter.tooltips_view
reloading plugin Text Pastry.text_pastry
reloading plugin Text Pastry.text_pastry_addons
reloading plugin Text Pastry.text_pastry_clipboard
reloading plugin Text Pastry.text_pastry_selection
reloading plugin Highlight.SublimeHighlight
reloading plugin PlainTasks.APlainTasksCommon
reloading plugin PlainTasks.PlainTasks
reloading plugin PlainTasks.PlainTasksDates
reloading plugin PlainTasks.PlainTasksToHTML
reloading plugin PlainTasks.plist_parser
plugins loaded
GhostText is starting now…
Setting on request handler
SublimeLinter: SublimeLinter.sublime-package:71: Logging installed; log level INFO
[2018-03-07 10:23:38,214 - INFO     - SublimeLinter] Logging installed; log level INFO
SublimeLinter: SublimeLinter.sublime-package:62: debug mode: on
[2018-03-07 10:23:38,235 - INFO     - SublimeLinter.sublime_linter] debug mode: on
SublimeLinter: SublimeLinter.sublime-package:63: version: 4.0.5
[2018-03-07 10:23:38,236 - INFO     - SublimeLinter.sublime_linter] version: 4.0.5
HTTP Start
SublimeLinter: SublimeLinter.sublime-package:256: detected syntax: javascript
[2018-03-07 10:23:38,542 - INFO     - SublimeLinter.sublime_linter] detected syntax: javascript
SublimeLinter: #1 SublimeLinter.sublime-package:782: 'eslint' is linting 'index.js'
[2018-03-07 10:23:38,552 - INFO     - SublimeLinter.lint.linter] 'eslint' is linting 'index.js'
SublimeLinter: #1 SublimeLinter.sublime-package:1184: eslint: index.js ['/Users/TooBug/work/usoption/node_modules/.bin/eslint', '--format', 'json', '--stdin', '--stdin-filename', '/Users/TooBug/work/usoption/server/index.js']
[2018-03-07 10:23:38,556 - INFO     - SublimeLinter.lint.linter] eslint: index.js ['/Users/TooBug/work/usoption/node_modules/.bin/eslint', '--format', 'json', '--stdin', '--stdin-filename', '/Users/TooBug/work/usoption/server/index.js']
SublimeLinter: #1 SublimeLinter.sublime-package:1187: eslint: cwd: /Users/TooBug/work/usoption
[2018-03-07 10:23:38,557 - INFO     - SublimeLinter.lint.linter] eslint: cwd: /Users/TooBug/work/usoption
SublimeLinter: #1 SublimeLinter.sublime-package:809: eslint output:
    env: node: No such file or directory
[2018-03-07 10:23:38,563 - INFO     - SublimeLinter.lint.linter] eslint output:
    env: node: No such file or directory
SublimeLinter: #1 SublimeLinter-eslint.sublime-package:50: ERROR: env: node: No such file or directory

[2018-03-07 10:23:38,564 - ERROR    - SublimeLinter.plugin.eslint] env: node: No such file or directory

Package Control: Skipping automatic upgrade, last run at 2018-03-07 10:05:22, next run at 2018-03-07 11:05:22 or after
environment variables loaded using: /bin/zsh -l
SublimeLinter: #2 SublimeLinter.sublime-package:782: 'eslint' is linting 'index.js'
[2018-03-07 10:23:58,878 - INFO     - SublimeLinter.lint.linter] 'eslint' is linting 'index.js'
SublimeLinter: #2 SublimeLinter.sublime-package:1184: eslint: index.js ['/Users/TooBug/work/usoption/node_modules/.bin/eslint', '--format', 'json', '--stdin', '--stdin-filename', '/Users/TooBug/work/usoption/server/index.js']
[2018-03-07 10:23:58,881 - INFO     - SublimeLinter.lint.linter] eslint: index.js ['/Users/TooBug/work/usoption/node_modules/.bin/eslint', '--format', 'json', '--stdin', '--stdin-filename', '/Users/TooBug/work/usoption/server/index.js']
SublimeLinter: #2 SublimeLinter.sublime-package:1187: eslint: cwd: /Users/TooBug/work/usoption
[2018-03-07 10:23:58,881 - INFO     - SublimeLinter.lint.linter] eslint: cwd: /Users/TooBug/work/usoption
SublimeLinter: #2 SublimeLinter.sublime-package:809: eslint output:
    [{"filePath":"/Users/TooBug/work/usoption/server/index.js","messages":[{"ruleId":null,"fatal":true,"severity":2,"source":"321***f0ewq;","message":"Parsing error: Unexpected token *","line":10,"column":6}],"errorCount":1,"warningCount":0,"source":"let Koa, config, middleware;\nKoa = require('koa');\nconfig = require('./config');\nmiddleware = require('./middleware');\n\nlet app = module.exports = new Koa();\n\n// middlewares are imported here.\nmiddleware(app, config);\n321***f0ewq;\n321******;;\napp.listen(config.server.port);\nconsole.log(`app[${app.env}] listen ${config.server.port} ...`);\n"}]
[2018-03-07 10:23:59,452 - INFO     - SublimeLinter.lint.linter] eslint output:
    [{"filePath":"/Users/TooBug/work/usoption/server/index.js","messages":[{"ruleId":null,"fatal":true,"severity":2,"source":"321***f0ewq;","message":"Parsing error: Unexpected token *","line":10,"column":6}],"errorCount":1,"warningCount":0,"source":"let Koa, config, middleware;\nKoa = require('koa');\nconfig = require('./config');\nmiddleware = require('./middleware');\n\nlet app = module.exports = new Koa();\n\n// middlewares are imported here.\nmiddleware(app, config);\n321***f0ewq;\n321******;;\napp.listen(config.server.port);\nconsole.log(`app[${app.env}] listen ${config.server.port} ...`);\n"}]
SublimeLinter: #2 SublimeLinter-eslint.sublime-package:56: eslint output:
[{'errorCount': 1,
  'filePath': '/Users/TooBug/work/usoption/server/index.js',
  'messages': [{'column': 6,
                'fatal': True,
                'line': 10,
                'message': 'Parsing error: Unexpected token *',
                'ruleId': None,
                'severity': 2,
                'source': '321***f0ewq;'}],
  'source': "let Koa, config, middleware;\nKoa = require('koa');\nconfig = require('./config');\nmiddleware = require('./middleware');\n\nlet app = module.exports = new Koa();\n\n// middlewares are imported here.\nmiddleware(app, config);\n321***f0ewq;\n321******;;\napp.listen(config.server.port);\nconsole.log(`app[${app.env}] listen ${config.server.port} ...`);\n",
  'warningCount': 0}]
[2018-03-07 10:23:59,454 - INFO     - SublimeLinter.plugin.eslint] eslint output:
[{'errorCount': 1,
  'filePath': '/Users/TooBug/work/usoption/server/index.js',
  'messages': [{'column': 6,
                'fatal': True,
                'line': 10,
                'message': 'Parsing error: Unexpected token *',
                'ruleId': None,
                'severity': 2,
                'source': '321***f0ewq;'}],
  'source': "let Koa, config, middleware;\nKoa = require('koa');\nconfig = require('./config');\nmiddleware = require('./middleware');\n\nlet app = module.exports = new Koa();\n\n// middlewares are imported here.\nmiddleware(app, config);\n321***f0ewq;\n321******;;\napp.listen(config.server.port);\nconsole.log(`app[${app.env}] listen ${config.server.port} ...`);\n",
  'warningCount': 0}]

STANDALONE FILE:

not in project, not working

image

SublimeLinter: SublimeLinter.sublime-package:256: detected syntax: javascript
[2018-03-07 10:24:35,104 - INFO     - SublimeLinter.sublime_linter] detected syntax: javascript
SublimeLinter: #3 SublimeLinter.sublime-package:782: 'eslint' is linting 'vm.js'
[2018-03-07 10:24:35,111 - INFO     - SublimeLinter.lint.linter] 'eslint' is linting 'vm.js'
SublimeLinter: #3 SublimeLinter.sublime-package:103: PATH:
    /Users/TooBug/.nvm/versions/node/v9.2.0/bin
    /usr/local/bin
    /usr/bin
    /bin
    /usr/sbin
    /sbin
    /usr/local/MacGPG2/bin
    /Applications/Wireshark.app/Contents/MacOS
[2018-03-07 10:24:35,111 - INFO     - SublimeLinter.lint.util] PATH:
    /Users/TooBug/.nvm/versions/node/v9.2.0/bin
    /usr/local/bin
    /usr/bin
    /bin
    /usr/sbin
    /sbin
    /usr/local/MacGPG2/bin
    /Applications/Wireshark.app/Contents/MacOS
SublimeLinter: WARNING: eslint cannot locate 'eslint' 

For those coming here with this problem: I found that in a project using only eslint the

"paths": {
		"osx": ["~/.nvm/versions/node/v8.11.4/bin"]
	},

solution works, but on a project using both eslint and sassLint it didn’t. so I ended up combining the linters solution and it now seems to work fine with both

"paths": {
		"osx": ["~/.nvm/versions/node/v8.11.4/bin"]
	},
	"linters": {
		"eslint": {
			"env": {"PATH": "~/.nvm/versions/node/v8.11.4/bin"}
		}
	}

I suspect that I could yank the path solution and the eslint solo project would work, but I didn’t try it.

This worked for me like a charm in Catalina. Make sure that eslint is installed via npm of-course.

// SublimeLinter Settings - User
{
    "linters": {
        "eslint": {
            "disable": false,
            "args": [],
            "executable": [
                "/Users/yannis/.nvm/versions/node/v13.14.0/bin/node",
                "/Users/yannis/.nvm/versions/node/v13.14.0/bin/eslint"
            ],
            "excludes": [],
            "lint_mode": "background"
        }
    },
}

Pretty unfortunate that I have to add a global .eslintrc to my home directory for this plugin to not display a big error message on every file in a project where I don’t have eslint setup. Would be nice if there was a setting that could disable this warning globally instead.

I have the same exact issue as @TooBug – is there a fix for this yet? it’s really annoying

image

This is an issue with Sublime Text: https://github.com/SublimeTextIssues/Core/issues/1877. ST core devs are aware of the issue and it has been moved upward in their priority list.

@kylebebak The paths setting is only used to find executables. If an executable depends on having other executables available in the environment, that’s not enough. Eslint needs node, so you need to patch the environment as you did.

The core of the problem here is that NVM takes too long, in certain setups, to report the actual environment to Sublime Text. Your shell only gets about a second to do so, after that your stuck with the environment desktop applications get by default, which on macOS is not the environment you get when you open Terminal. @nodkrot you may not run into this issue if you don’t use nvm on the other machine, or the other machine is simply faster and does report the environment to ST before it times out.

Behavior of Sublime Text changed in 3.1 to have this 1 second time out, and thereby also removing the possibility for plugins to create a work around. The TS issue linked here doesn’t seem to actually resolve this issue and in any case the actual problem and possible solutions changed recently in Sublime Text 3.1 (and this issue is older than that).

Not working for me! I tried everything here. Sublime seems broken tbh, too much work to get a simple lint to work 😦

I got stuck on the env: node: No such file or directory error, and none of the proposed solutions worked (updating paths.osx, updating linters.standard.env.PATH). I’m running macOS High Sierra, using zsh with oh-my-zsh, using NVM, and I was trying to use the standard linter installed in my project, rather than a global install.

I finally got things working by using the executable option, in my project settings, to point to Node and Standard as well. Here’s what I added:

{
  // ... other project settings
  "settings":
  {
    "SublimeLinter.linters.standard.executable":
    [
      "$HOME/.nvm/versions/node/v8.12.0/bin/node",
      "${project_path}/node_modules/.bin/standard"
    ]
  }
}

It might be worth looking at what GoSublime is doing - even when my sublime isn’t loading my path correctly, GoSublime seems to do its own path loading and reports the results to sublime’s console.

EDIT: Since we’re posting what fixed this for us, I fixed this issue by upgrading to Arch Linux from macOS.

As @bdefore commented 4 days earlier, @thislogancall 's change to settings doesn’t fix the error. My sublimelinter settings:

{ [....] "paths": { "osx": ["~/.rvm/gems/ruby-2.3.3/bin", "~/.nvm/versions/node/v10.0.0/bin", ] }, [...]