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

Cannot use with ES modules due to package.json #920

Open
StefanOctavian opened this issue Sep 1, 2022 · 0 comments
Open

Cannot use with ES modules due to package.json #920

StefanOctavian opened this issue Sep 1, 2022 · 0 comments

Comments

@StefanOctavian
Copy link

StefanOctavian commented Sep 1, 2022

Describe the bug
Due to nope's package.json not having "type": "module", when I try to use nope-validator with es modules I get an error SyntaxError: Cannot use import statement outside a module. My project does indeed have "type": "module" in its own package.json, the error I get only shows up when importing from 'nope-validator'. If I go to node_modules/nope-validator/package.json and just add the type field, everything works fine (but I think it wouldn't work anymore if I decided to switch to commonJs).

To reproduce
Steps to reproduce the behavior:
Create a fresh npm project, add "type": "module" to your "package.json"; Run npm install -S nope-validator ; Let the entry point be index.js. Open index.js and write:

import Nope from 'nope-validator'

Run node index.js.

Expected behavior
I expected it not to throw any errors.

Environment:

  • Node version: v16.16.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant