Cannot start nuxt: Cannot use import statement outside a module
See original GitHub issueHi,
Since yesterday Nuxt doesnt start with nuxt-graphql-client. Please check your Stackblitz from Quick Start, im getting the same error. https://stackblitz.com/edit/nuxt-graphql?file=README.md
package.json hasn’t change, I dont know how to roll back or what has changed.
cosmiconfig-typescript-loader has import { TypeScriptLoader } from "./loader";
but I dont see any recent changes in this repo
thank you
error:
ERROR (node:11056) Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension. 08:49:58
(Use `node --trace-warnings ...` to show where the warning was created)
ERROR Cannot start nuxt: Cannot use import statement outside a module 08:49:58
import { TypeScriptLoader } from "./loader";
^^^^^^
SyntaxError: Cannot use import statement outside a module
at Object.compileFunction (node:vm:352:18)
at wrapSafe (node:internal/modules/cjs/loader:1033:15)
at Module._compile (node:internal/modules/cjs/loader:1069:27)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at ModuleWrap.<anonymous> (node:internal/modules/esm/translators:170:29)
at ModuleJob.run (node:internal/modules/esm/module_job:198:25)
at async Promise.all (index 0)
at async ESMLoader.import (node:internal/modules/esm/loader:385:24)
ERROR [unhandledRejection] Cannot use import statement outside a module 08:49:58
08:49:58
import { TypeScriptLoader } from "./loader";
^^^^^^
SyntaxError: Cannot use import statement outside a module
at Object.compileFunction (node:vm:352:18)
at wrapSafe (node:internal/modules/cjs/loader:1033:15)
at Module._compile (node:internal/modules/cjs/loader:1069:27)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at ModuleWrap.<anonymous> (node:internal/modules/esm/translators:170:29)
at ModuleJob.run (node:internal/modules/esm/module_job:198:25)
at async Promise.all (index 0)
at async ESMLoader.import (node:internal/modules/esm/loader:385:24)
Issue Analytics
- State:
- Created a year ago
- Reactions:1
- Comments:7 (3 by maintainers)
Top Results From Across the Web
Cannot use import statement outside a module using nuxtjs
If you get an Cannot use import statement outside a module error, you may need to add your package to the build >...
Read more >"Cannot use import statement outside a module" ( Nuxt.js ) · ...
Getting this error when using Nuxt.js. The component is wrapped in a client-only tag to avoid any SSR issues.
Read more >Nuxt.js and Three.js production build - Cannot use import ...
Here i'm importing the plugins from the jsm folder, i have tried importing this from the js folder but then i get THREE...
Read more >Getting error `Cannot use import statement outside a ...
That means whatever tool/framework you are using doesn't support ES Modules, so you would need to import the UMD files. This is a...
Read more >Fix - Cannot use import statement outside module Error in Node
If you are using a node application and want to use the import statement, then you will also get the "Cannot use import...
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
@tasiotas @michtio @DenFin
This has been resolved. Be sure to upgrade the module to
v0.1.7
, delete thenode_modules
folder and your lockfile@tasiotas @michtio @DenFin A quick update. We’ve narrowed it down to a strange ESM module resolution bug upstream in two different dependencies. A fix is on the way.