1

Following the instructions located at https://packagecontrol.io/packages/ESLint, I installed Node.JS, then installed ESLint, then opened Sublime Text Editor and used the Command Palette to install the ESLint package per the instructions. But when I try to lint a javascript file using CTRL-ALT-E, I get the following error message in my sublime text console stating it cannot find the file ESLint. It's acting as if the program is not installed even though I can clearly see ESLint commands listed in Sublime text's Package Settings and Tools menu, including the option to lint the open file.

Here is the error message I receive in Sublime Text console:

node:internal/modules/cjs/loader:1078
  throw err;
  ^

Error: Cannot find module 'eslint'
Require stack:
- C:\Users\Dennis\AppData\Roaming\Sublime Text 3\Packages\ESLint\linter.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1075:15)
    at Function.resolve (node:internal/modules/cjs/helpers:116:19)
    at Object.<anonymous> (C:\Users\Dennis\AppData\Roaming\Sublime Text 3\Packages\ESLint\linter.js:19:13)
    at Module._compile (node:internal/modules/cjs/loader:1254:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1308:10)
    at Module.load (node:internal/modules/cjs/loader:1117:32)
    at Module._load (node:internal/modules/cjs/loader:958:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
    at node:internal/main/run_main_module:23:47 {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    'C:\\Users\\Dennis\\AppData\\Roaming\\Sublime Text 3\\Packages\\ESLint\\linter.js'
  ]
}

Node.js v18.16.0
[Finished in 113ms]

This is after the second time I've uninstalled Node and reinstalled it, then tried reinstalling ESLint, and Sublime Text's ESLint plugin per the instructions above. At this point I don't know where to start troubleshooting.

I am using sublime build 4143, and sublime update function confirms this is the latest version.

Expected to run ESLint in sublime and get syntax highlighting for any code that does not conform to Sublime's default syntax rules.

Update on steps taken to address. Following suggestion to configure node_path settings for the sublime text plugin, I opened Sublime, went to the menu preferences -> Package Settings -> ESLine -> Settings-User, and changed the ESLint.sublime-settings--User file as follows:

  // The directory location of your `node` executable lives. If this is not
  // specified, then it is expected to be on Sublime's environment path.
  //
  // On OSX, for example: "/usr/local/bin"
  // Example for nodebrew: "$HOME/.nodebrew/current/bin"
  // Example for Windows: "C:/Program Files/nodejs"
  "node_path": "C:/Program Files/nodejs"

That is where my node executable and folder is, while Sublime Text is actually located on my other hard drive, E:

I tried closing sublime and reopening it and running ESLint in sublime still gives same error.

dennis
  • 21
  • 3
  • Some questions: after you installed Node, did you run `npm install -g eslint` successfully? Second, did you configure `"node_path"` in the plugin's settings (not the `.eslintrc` file)? Also, did you restart Sublime after installing Node and the `eslint` module via `npm`? – MattDMo May 26 '23 at 15:08
  • The other suggestions I will have to look into and try out. – dennis May 27 '23 at 00:51
  • So I tried MattDMo's suggestions above, same error message, please see my edits to question body. I had a question about what he meant by saying install Node and eslint via npm, though. I installed eslint globally using npm in my terminal while I downloaded the Node 18 via their website and ran the setup program they provided, like it shows in the following tutorial: https://treehouse.github.io/installation-guides/windows/node-windows.html. Does this make a difference? – dennis May 27 '23 at 01:08
  • Here is what I saw when I installed eslint using npm: `[Web Dev]: /vagrant/src $ npm install -g eslint /home/vagrant/.nvm/versions/node/v7.2.0/bin/eslint -> /home/vagrant/.nvm/versions/node/v7.2.0/lib/node_modules/e slint/bin/eslint.js + eslint@8.41.0 added 1 package, removed 2 packages and updated 6 packages in 14.402s` – dennis May 27 '23 at 01:11
  • Hold on... you're installing `eslint` with `npm` from a Linux prompt, yet you're saying Node is installed in `C:\Program Files`? How is that? – MattDMo May 27 '23 at 02:15
  • I have a VM on my windows 10 computer I use for programming. I downloaded Node from their website and installed it to the default drive, which is C: – dennis May 27 '23 at 02:16
  • 1
    Sublime, Node, `npm`, and `eslint` all need to be installed in the same operating system, so that they can all see each other. In particular, Sublime needs to be able to use Node to run `eslint`. With `eslint` being installed in your VM (Linux), Sublime can't see it from Windows, hence the error message: `Error: Cannot find module 'eslint'`. Put everything together in the same OS, and it should work. – MattDMo May 27 '23 at 02:23

0 Answers0