SyntaxError: Cannot use import statement outside a module
See original GitHub issueSteps to reproduce
Install into feathers v4 app using js.
server/node_modules/feathers-authentication-management/dist/index.js:1
import setup from './setupAuthManagement';
^^^^^^
SyntaxError: Cannot use import statement outside a module
at Object.compileFunction (node:vm:352:18)
at wrapSafe (node:internal/modules/cjs/loader:1027:15)
at Module._compile (node:internal/modules/cjs/loader:1063:27)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at Module.load (node:internal/modules/cjs/loader:975:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:999:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Module._compile (node:internal/modules/cjs/loader:1099:14)
Node.js v17.9.1
- Tell us what broke. The more detailed the better.
- Include the
feathers-gen-specs.json
file from your app. - Include the
src/services/[serviceName]/[serviceName].schema.?s
files if the issue involves the fields in one or more services.
These last 2 items usually allow us to regen enough of your app to recreate the issue. We may otherwise ask you to provide a minimal GitHub repo or gist isolating the issue.
Expected behavior
Tell us what should happen
Actual behavior
Tell us what happens instead
System configuration
Tell us about the applicable parts of your setup.
Module versions (especially the part that’s not working):
NodeJS version:
Operating System:
Browser Version:
React Native Version:
Module Loader:
Issue Analytics
- State:
- Created a year ago
- Comments:10
Top Results From Across the Web
"Uncaught SyntaxError: Cannot use import statement outside ...
This means that you're using the native source code in an unaltered/unbundled state, leading to the following error: Uncaught SyntaxError: ...
Read more >Cannot use import statement outside a module [React ...
When building a web application, you may encounter the SyntaxError: Cannot use import statement outside a module error.
Read more >Cannot use import statement outside module in JavaScript
The "SyntaxError: Cannot use import statement outside a module" occurs when we use the ES6 Modules syntax in a script that was not...
Read more >How to fix "cannot use import statement outside a module"
I stumbled on this error: Uncaught SyntaxError: cannot use import statement outside a module while importing a function from a JavaScript ...
Read more >How to solve: cannot use import statement outside a module
When you see the error message Uncaught SyntaxError: cannot use import statement outside a module, it means you're using an import statement ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’ll publish a commonJS version of the package 👍
What module version are you using v3 or v4 ? Usually this error is linked to the fact you are trying to import an ES module into a CommonJS module. You might have to set the
type
property tomodule
in yourpackage.json
file if you are working with ES modules. Maybe it is related to typescript so that the code is not correctly transpiled. However I will not be able to help on that, @fratzinger might help ?