polygonplanet / sublime-text-eslint

ESLint any JavaScript file in Sublime Text
24 stars 7 forks source link

Error: Cannot find module 'eslint' #9

Closed programmist closed 6 years ago

programmist commented 7 years ago

I'm getting the following error when I try to run ESLint within Sublime 3.

module.js:472
    throw err;
    ^

Error: Cannot find module 'eslint'
    at Function.Module._resolveFilename (module.js:470:15)
    at Function.Module._load (module.js:418:25)
    at Module.require (module.js:498:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/Users/userx/Library/Application Support/Sublime Text 3/Packages/ESLint/linter.js:11:17)
    at Module._compile (module.js:571:32)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
[Finished in 0.1s with exit code 1]
[cmd: ['node', '/Users/userx/Library/Application Support/Sublime Text 3/Packages/ESLint/linter.js', '/Users/userx/workspace/react/first-app/src/App.js', '', '']]
[dir: /Users/userx/workspace/react/first-app/src]
[path: /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/go/bin]

Steps to Reproduce:

System:

This may be a regression of #2, but unfortunately the discussion in that issue did not help me.

Thank you.

polygonplanet commented 7 years ago

Maybe your node_modules pass does not match. You can check your global node_modules path by

$ npm root -g

command. and try set your sublime eslint's "node_modules_path" to displayed path.

programmist commented 7 years ago

Thank you. I checked both both paths before setting them in Sublime. When I run npm root -g I get /usr/local/lib/node_modules, which is what I have set for node_modules_path.

polygonplanet commented 7 years ago

Does the following command output something in your environment? or empty?

$ echo $NODE_PATH
jkirkwood commented 7 years ago

The latest versions of node and npm no longer add the global node_modules directory to $NODE_PATH. See this.

Could this package be updated to use the eslint binary installed by npm install eslint -g directly? It looks like this is how the sublime-jshint package handles this.

jkirkwood commented 7 years ago

Running npm link eslint in the Sublime ESLint package directory appears to provide a temporary workaround.

programmist commented 7 years ago

@polygonplanet Apologies, I'd forgotten to reply. My NODE_PATH env variable is not set.

$ echo $NODE_PATH

$
polygonplanet commented 7 years ago

@jkirkwood thanks for your hint! @programmist OK, As in nodejs document, if the following pass is valid, try setting "node_modules_path": "$HOME/.node_modules" etc.

  1. $HOME/.node_modules
  2. $HOME/.node_libraries
  3. $PREFIX/lib/node

Or, try to set "node_modules_path": "", and enter following command in terminal:

cd YOUR_SUBLIME_ESLINT_PACKAGES_FOLDER
# example: cd /Users/userx/Library/Application Support/Sublime Text 3/Packages/ESLint
npm link eslint
programmist commented 7 years ago

I'm good if you want to close this. Or let me know and I'll close it. Thanks for your help.

mdaross-ha commented 7 years ago

I just tried to install ESLint, and got the same error. Upon running npm link eslint in my ESLint package folder, I now get: /usr/local/lib/node_modules/eslint/lib/util/module-resolver.js:74 throw new Error(Cannot find module '${name}'\); ^

Error: Cannot find module 'babel-eslint' at ModuleResolver.resolve (/usr/local/lib/node_modules/eslint/lib/util/module-resolver.js:74:19) at loadFromDisk (/usr/local/lib/node_modules/eslint/lib/config/config-file.js:544:42) at Object.load (/usr/local/lib/node_modules/eslint/lib/config/config-file.js:592:20) at Config.getLocalConfigHierarchy (/usr/local/lib/node_modules/eslint/lib/config.js:228:44) at Config.getConfigHierarchy (/usr/local/lib/node_modules/eslint/lib/config.js:182:43) at Config.getConfigVector (/usr/local/lib/node_modules/eslint/lib/config.js:287:21) at Config.getConfig (/usr/local/lib/node_modules/eslint/lib/config.js:330:29) at processText (/usr/local/lib/node_modules/eslint/lib/cli-engine.js:162:33) at processFile (/usr/local/lib/node_modules/eslint/lib/cli-engine.js:245:18) at executeOnFile (/usr/local/lib/node_modules/eslint/lib/cli-engine.js:585:25)

polygonplanet commented 7 years ago

@mdaross-ha Did you install eslint npm install -g eslint ?

mdaross-ha commented 7 years ago

Yes, I did that before trying to install the plugin.

From: polygon planet notifications@github.com Reply-To: polygonplanet/sublime-text-eslint reply@reply.github.com Date: Friday, July 14, 2017 at 7:16 PM To: polygonplanet/sublime-text-eslint sublime-text-eslint@noreply.github.com Cc: Michael Daross mdaross@homeaway.com, Mention mention@noreply.github.com Subject: Re: [polygonplanet/sublime-text-eslint] Error: Cannot find module 'eslint' (#9)

@mdaross-hahttps://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_mdaross-2Dha&d=DwMCaQ&c=tmh68fGhvYqZefO02qmwIQ&r=P8zvuXdNS0F_6ytNCVDDU3o1iKS2Y9qd9Z13W-m5hx8&m=TkhWc_VUcizm1yEhGBAgGYsUlRIJiut0IXW6l6QeDLA&s=WLaC2Zz7PnwQLSmU2PAqnOYaV1FOH5ODuqjjkHnFMIU&e= Did you install eslint npm install -g eslint ?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_polygonplanet_sublime-2Dtext-2Deslint_issues_9-23issuecomment-2D315495313&d=DwMCaQ&c=tmh68fGhvYqZefO02qmwIQ&r=P8zvuXdNS0F_6ytNCVDDU3o1iKS2Y9qd9Z13W-m5hx8&m=TkhWc_VUcizm1yEhGBAgGYsUlRIJiut0IXW6l6QeDLA&s=oOpNOLoVg_BkcbIZOobR_VCQ07m4aLKoU3zp_gf8QgA&e=, or mute the threadhttps://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_notifications_unsubscribe-2Dauth_AbyA2ggLqUvCWa2qccw00KTmzEMqJzyrks5sOATDgaJpZM4MH-2Dpb&d=DwMCaQ&c=tmh68fGhvYqZefO02qmwIQ&r=P8zvuXdNS0F_6ytNCVDDU3o1iKS2Y9qd9Z13W-m5hx8&m=TkhWc_VUcizm1yEhGBAgGYsUlRIJiut0IXW6l6QeDLA&s=b9gAuzl941uegY82-ZUL3bV9STLZk7p1VhCuSuRHD-4&e=.

jt3k commented 7 years ago

same problem

yinglinchen-minted commented 7 years ago

I got same problem

englishextra commented 7 years ago

manually:

// C:\Users\<USERNAME>\AppData\Roaming\Sublime Text 3\Packages\User\ESLint.sublime-settings
{
  "node_modules_path": "C:\\Users\\<USERNAME>\\AppData\\Roaming\\npm\\node_modules",
}
polygonplanet commented 6 years ago

If the problem is not solved yet, we want to know more detail. We close this issue once.

codingdash commented 6 years ago

If you're still facing issue after adding node_modules_path. Restart Sublime Text!

charanjit-singh commented 5 years ago

installing eslint and babel-eslint locally ( using --save option ) worked for me.

ParikshitSarkar commented 4 years ago

Running npm link eslint in the Sublime ESLint package directory appears to provide a temporary workaround.

Thanks ! :)