Skip to content
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

ERROR in ./node_modules/@capacitor-community/file-opener/dist/esm/index.js 3:0-30 #14

Closed
pkaplan2524 opened this issue Oct 27, 2022 · 10 comments
Assignees
Labels
bug Something isn't working
Milestone

Comments

@pkaplan2524
Copy link

I'm building an app with create-react-app and am getting the following error when adding file-opener.

ERROR in ./node_modules/@capacitor-community/file-opener/dist/esm/index.js 3:0-30
Module not found: Error: Can't resolve './definitions' in 'PATHTOAPP/client/node_modules/@capacitor-community/file-opener/dist/esm'
Did you mean 'definitions.js'?
BREAKING CHANGE: The request './definitions' failed to resolve only because it was resolved as fully specified
(probably because the origin is strict EcmaScript Module, e. g. a module with javascript mimetype, a '.mjs' file, or a '.js' file where the package.json contains '"type": "module"').
The extension in the request is mandatory for it to be fully specified.
Add the extension to the request.

It does work when I edit the file ./node_modules/@capacitor-community/file-opener/dist/esm/index.js line 3 to read:

export * from './definitions.js'.

But, can't have the entire team editing files in node_modules.

@arendjantetteroo
Copy link

I got sort of the same issue with 1.0.2, where 1.0.1 works. Did you try 1.0.1?

@ryaa ryaa added the bug Something isn't working label Oct 28, 2022
@ryaa ryaa self-assigned this Oct 28, 2022
@arendjantetteroo
Copy link

@ryaa i got the following error message when building this through a nextjs project (typescript).

#43 238.4 Error occurred prerendering page "/help-center". Read more: https://nextjs.org/docs/messages/prerender-error
#43 238.4 ReferenceError: require is not defined in ES module scope, you can use import instead
#43 238.4 This file is being treated as an ES module because it has a '.js' file extension and '/usr/src/pwa/node_modules/.pnpm/@[email protected]_@[email protected]/node_modules/@capacitor-community/file-opener/package.json' contains "type": "module". To treat it as a CommonJS script, rename it to use the '.cjs' file extension.
#43 238.4     at file:///usr/src/pwa/node_modules/.pnpm/@[email protected]_@[email protected]/node_modules/@capacitor-community/file-opener/dist/plugin.cjs.js:3:12
#43 238.4     at ModuleJob.run (node:internal/modules/esm/module_job:193:25)
#43 238.4     at async Promise.all (index 0)
#43 238.4     at async ESMLoader.import (node:internal/modules/esm/loader:518:24)
#43 238.4     at async importModuleDynamicallyWrapper (node:internal/vm/module:438:15)

1.0.1 works fine.

@pkaplan2524
Copy link
Author

Tried backing up to 1.0.1 to see if that would help, but that gave me an error about node versions on install.

@arendjantetteroo
Copy link

arendjantetteroo commented Oct 28, 2022

Looking at the commit that broke it and the error message, it seems it's the addition of "type": "module" to package.json.

Looking at a couple other community plugins i don't see them having type:module. If they have something related, it's like this:

  "main": "dist/plugin.cjs.js",
  "module": "dist/esm/index.js",
  "types": "dist/esm/index.d.ts",

@ryaa hope this helps, i'm not sure what type:module should do or why you added it?

@ryaa ryaa added the question Further information is requested label Oct 28, 2022
@ryaa
Copy link
Member

ryaa commented Oct 28, 2022

I think I made the change to fix this - see. Can someone, having this problem, please install the version of the plugin with the fix and see if it helps. To install please issue the below command:
npm install capacitor-community/file-opener#bugfix/build-1.0.2-fails-to-install-with-dist

If the above does not help, i will need a sample application (repository in the GitHub with the detailed installation/build steps) that demonstrates the issue.

@pkaplan2524
Copy link
Author

Can confirm. This addressed the issue I was having. Thank you!

@ryaa ryaa added this to the v1.0.3 milestone Oct 29, 2022
@ryaa
Copy link
Member

ryaa commented Oct 29, 2022

Will release this change in 1.0.3 very soon.

@ryaa ryaa closed this as completed Oct 29, 2022
@ryaa ryaa removed the question Further information is requested label Oct 29, 2022
@arendjantetteroo
Copy link

@ryaa didn't help for me. will open a new issue.

@ryaa
Copy link
Member

ryaa commented Oct 31, 2022

@ryaa didn't help for me. will open a new issue.

can you please provide a sample application (repository in the GitHub) that demonstrates the issue. Thank you.

@arendjantetteroo
Copy link

@ryaa thanks, see #18

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants