-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to resolve path to module (import/no-resolved) only in Sublime text 3 #139
Comments
Have you tried the SublimeLinter instructions from the README? That would be the first step. Also: for the webpack resolver to work, a separate config file is a must if you have any |
Link to SublimeLinter steps; https://github.com/benmosher/eslint-plugin-import/blob/master/README.md#sublimelinter-eslint |
I have 12 pages to build, so in this case I will need 12 webpack.config.js I did all steps from README before I made an issue. Without this steps I 2015-12-06 4:39 GMT+08:00 Ben Mosher notifications@github.com:
|
ohhhhh, okay, I think you probably need to move "jsx: true" from "settings" to "ecmaFeatures" in your eslintrc. The plugin has its own dependency parser that doesn't parse JSX by default, but will respect the ecmaFeatures.jsx flag. Also: if you find that still doesn't work, adding |
BTW: You can specify 12 entry files in a single Webpack config, and it will build all of them. I'm not sure how that would integrate with Gulp, though. I used to use Gulp for Webpack but I found it to be simpler to build CSS bundles with Gulp and use Webpack's CLI directly for JS. YMMV. |
I know that I can specify 12 entry files , but I have sequence tasks. I 2015-12-07 3:53 GMT+08:00 Ben Mosher notifications@github.com:
|
Fair enough. Shortest path to success is probably adding |
putting "import/parser": "babel-eslint" to the settings doesn't help( rule "import/no-unresolved": [2, {commonjs: true, amd: true}], still giving I do not have problems in build process, only in sublime text for now I set "import/no-unresolved": [0, {commonjs: true, amd: true}] 2015-12-07 19:29 GMT+08:00 Ben Mosher notifications@github.com:
|
Hmm... I'm really not sure what might be happening. A second look through your config + what you've posted doesn't yield any more ideas... I'll keep thinking about it |
Ohhh, so: you need to add |
By now, I will not use this option. Thank you very much, keep in touch) 2015-12-07 22:55 GMT+08:00 Ben Mosher notifications@github.com:
|
Can't blame you. 😅 I will close for now, let me know if/when you want to dig in again, I can reopen. Also if anyone else has similar issues and can figure out reproduction steps, feel free to post here. Sorry it isn't working! |
I kill the night to unite js build process now I have all entries in 1 webpack.config.file, I set "import/resolver": "webpack" to settings, and I start to receive same import errors in build process. after that I add "import/resolver": "babel-eslint" to "settings",
and I stop to receiving errors in build process, but still have it in 2015-12-07 23:57 GMT+08:00 Ben Mosher notifications@github.com:
|
I am also seeing this issue, only when using SublimeLinter-eslint. // /foo.js
import baz from './bar/baz'; // /bar/baz.js
import x from './x'; The error only appears inside nested files, i.e. the import for |
@OliverJAsh: would you be up for building a toy example I can debug against? I've been unable to replicate on my end thus far. I've seen that behavior before, but the SublimeLinter-eslint workaround has been working for me, and hopefully with my next publish of the Node resolver, the workaround is not needed anymore. Unless maybe it's an |
well, I have my import/export organized like this: import { func1, func2 } from "./dir/file"; const func4 = (func1, func2, func3) {...}; export { func4 }; 2015-12-09 4:58 GMT+08:00 Ben Mosher notifications@github.com:
|
Update: I think I found a cleaner workaround for the SublimeLinter-eslint integration; see the updated README about the |
Ben, I create project file in sublime and make it { it doesn't help ( 2015-12-14 19:56 GMT+08:00 Ben Mosher notifications@github.com:
|
Dang. Could try just What OS are you on? I just realized I can't tell from the stuff you've provided so far, I guess I had assumed OS X. If you're on Windows, could be something nutty related to that? (though even then, I wouldn't know where to start, I don't have access to a Windows box) |
I'm on Mac, last version updated, Node 5.1.0 2015-12-14 23:29 GMT+08:00 Ben Mosher notifications@github.com:
|
Sublime text 3 2015-12-15 1:35 GMT+08:00 Alexey Lyahov justfly1984@gmail.com:
|
BTW, I fount that if I remove "import/parser": "babel-eslint" from 2015-12-15 1:35 GMT+08:00 Alexey Lyahov justfly1984@gmail.com:
|
I'm curious if you still have this issue as of ESLint 2.x + the 1.0.0+ version of this plugin. |
Closing due to inactivity, just let me know if you want to pick this back up if it's still not working. |
Stil having the issue, sublime 3 latest eslint latest plugin version |
The workaround that worked for me was: Preferences > Packages settings > SublimeLinter > Settings [User] Then add |
Still doesn't work for me either( 2016-03-09 20:50 GMT+07:00 Vincent Voyer notifications@github.com:
|
I think I might petition @roadhump to remove the .eslintignore behavior from the Sublime plugin now that ESLint 2 is released. IIRC it should be unnecessary now. |
I had a different problem with the same error. I added the following line to my
|
Thanks, @emorikawa! Had the same error for imports of Adding the following settings helped: Before that tried different settings, including Using version 1.6.1. |
@mikatuo's solution solved it for me - needed |
I have tried everything in the README, as well as every single proposed solution in this issue. SetupMy installed versions: {
"eslint-import-resolver-webpack": "^0.8.0",
"eslint-plugin-import": "^2.2.0"
} My problemI am getting the following linting errors ONLY on Sublime 3. If I run eslint from the console, I do not get these errors at all:
The codeFrom import initStore from 'setup/store'; Note again that this works in every instance, just not on Sublime 3 for some reason. Config filesMy Webpack config uses // ...
resolve: {
root: path.resolve('./src'),
extensions: ['', '.js'],
},
// ... I put in a
In my
And finally, my {
"ecmaFeatures": {
"jsx": true,
"modules": true
},
"env": {
"browser": true,
"es6": true,
"node": true
},
"parser": "babel-eslint",
"extends": "eslint-config-airbnb",
"rules": {
"react/jsx-filename-extension": [1, { "extensions": [".js", ".jsx"] }],
},
"plugins": [
"react"
],
"settings": {
"import/extensions": [".js", ".jsx"],
"import/parser": "babel-eslint",
"import/resolver": {
"node": {
"extensions": [".js", ".jsx"]
},
"webpack": {
"config": "webpack.dev.config.js"
}
}
}
} What am I missing? |
I just want to add that I got it working when I realized that there is a difference between global eslint file and local (in the project) eslint file. Also you need to install eslint-import-resolver-webpack. |
@adrianmcli no obvious problems (it's been forever since I've debugged this, though) but you could try an absolute path to your |
@adrianmcli did you figure out a fix? |
@benmosher thanks for the suggestion. I did as you suggested and validated that the config was found by adding in a console.log('config found'); Inside the Sublime console, I get this:
So at least we know that the config file is being found properly. What else can I check for? @mahdt as you can see, I'm still struggling with this issue. I used a lot of |
@adrianmcli I just figured out the issue I had.
Originally in my projectRoot/webpack/webpack.eslint.js file, I had
Even though this works with Atom, it does not with Sublime. I realized that Sublime was changing the context (process.cwd()) to the directory of the open file. Thus eslint was unable to find the local modules.
So I was able to fix the problem by providing the full path to my src directory. |
@mahdt BRILLIANT! This worked. Thanks so much for digging into this. |
@mahdt worked for me too! 😀 I was trying to use |
using
worked for me. Should add this to the README |
@mahdt's solution worked for me - though I was having the issues in vscode, not sublime. However, I needed a slight modification to correctly resolve imports from So here was my final solution: // .eslintrc.js
const path = require("path");
const config = {
resolve: {
modules: [
path.resolve(__dirname, "src"),
path.resolve(__dirname, "node_modules")
]
}
};
module.exports = {
settings: {
"import/resolver": {
webpack: {
config
}
}
}
}; |
I have an Error "Unable to resolve path to module" (import/no-resolved) only in Sublime text 3 for any of my es6 module import statements. At the same time, I have no problems with bundling, and properly working highlighted export of multiple variables, e.g. :
and other eslint-plugin-import rules
I have node 5.0.0 installed via nvm, all dependency modules removed, and npm i
this is totally wierd( I kill 2 days for it.
can't use "eslint-import-resolver-webpack": "^0.1.4", because I use gulp-webpack plugin with configuration in gulpfile.js instead of separate webpack.config.js , and have several pages in build process.
I'm trying to slowly integrate ReactJS in my project, which I have frameworkless pure functional ES5, and now I'm converting it to ES6, before I can start with React and single webpack.config.js
Please, can somebody help me out? I kill 2 days desperately fight this problem.
.eslintrc
package.json
.sublimelinterrc
SublimeLinter.sublime-settings
The text was updated successfully, but these errors were encountered: