ably-js
ably-js copied to clipboard
2.0.1 with eslint give 'Unable to resolve path to module 'ably' import/no-unresolved'
There is something wrong with your node_module export, because the plugin eslint-plugin-import complains.
I got this error after i upgraded to 2.0.0.
My application still works, so its just limited to the linter.
Here is a minimum that i think reproduce it
frontend/package.json
{
"dependencies": {
"ably": "2.0.1"
},
"devDependencies": {
"eslint-plugin-import": "^2.29.0"
},
"eslintConfig": {
"env": {
"browser": true,
"es2021": true
},
"extends": [
"plugin:import/recommended"
]
}
}
frontend/main.js
import * as Ably from "ably"
Then run something like .\frontend\node_modules\.bin\eslint ./frontend/
->
C:\Repos\untitledgame\frontend\static\game\js\event-subscriber.js
1:23 error Unable to resolve path to module 'ably' import/no-unresolved
✖ 1 problem (1 error, 0 warnings)
Workaround:
import * as Ably from "ably" // eslint-disable-line import/no-unresolved
Hey @Andrioden, thanks for the report and repro! It seems like this is just a manifestation of https://github.com/import-js/eslint-plugin-import/issues/2703, which is an issue with eslint-plugin-import not being able to parse the package.json exports field. We will look into the impact of adding a "main" field to our package.json or if there are any other ways for us to mitigate this but for now, simply disabling the plugin (as you are doing in the workaround) is probably the best way to go.