Closed enricodeleo closed 3 years ago
I had this same issue simply following the Capacitor Docs guide using Vue/Ionic and it seems that for me that was the issue. I tried it with React and had no problems. I'm guessing it has something to do with how Vue/Ionic is linting? It doesn't seem to like the Capacitor Plugin boilerplate code as a dependency. Were you having this issue with a different framework too or were you also using Vue?
Having the same issue with a fresh start on a Vue app.
To provide further details, here's the exact steps I took (which are super minimal) to recreate the issue:
I just started from total scratch, so first I made a new Ionic app via ionic start kcmapp blank --vue
once that completed, I opened the folder and ran npm install
Then I started the capacitor plugin project via npm init @capacitor/plugin
... once that completed I opened the folder and ran npm install
followed by npm run build
Back in the ionic project, I ran npm install ../kcm-video-recorder
(the directory the capacitor plugin sits in) ... which works fine. In the Home.vue file, I added import {KcmVideoRecorder} from 'kcm-video-recorder';
and then on mounted, I added console.log(KcmVideoRecorder.echo({value:"test"}));
Now when I run ionic serve
I get this error:
Syntax Error: Error: Failed to load plugin 'import' declared in '..\kcm-video-recorder\package.json » @ionic/eslint-config/recommended': Cannot find module 'eslint-plugin-import'[vue-cli-service] Require stack:
[vue-cli-service] - C:\Users\Jake\Documents\Code\kcmapp\__placeholder__.js
[vue-cli-service] Referenced from: C:\Users\Jake\Documents\Code\kcm-video-recorder\node_modules\@ionic\eslint-config\recommended.js
There are two problems:
2 only worked for me after doing 1 too, not sure if .eslintignore doesn't work on eslint 6, there might be other ways of making eslint not lint your plugin, but I don't know much about eslint.
Looks like vue tooling already uses eslint 7 in the dev branch, so hopefully this will be fixed on their next release.
Closing since it's not a bug in the generator.
I have removed the eslint 7 from my capacitor plugin. It worked. Thanks @jcesarmobile.
Whenever I try to build the src with
npm run build
I get no errors at build time but I do in my application when importing the plugin with the error:Is it just me?
I run node v15.13.0 and npm 7.7.6