-
Notifications
You must be signed in to change notification settings - Fork 44
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
SyntaxError: Cannot use import statement outside a module #63
Comments
Same problem, using NestJS |
Fix: Update the config file. You might have to make some changes to your vite config file if you are using vite. import { defineConfig } from "@solidjs/start/config";
export default defineConfig({
vite: {
ssr: {
noExternal: ["pdf-img-convert", "node-fetch"],
},
},
}); I also experienced this error in my project using solidjs. Cannot use import statement outside a module
/.../node_modules/.pnpm/pdf-img-convert@2.0.0_encoding@0.1.13/node_modules/pdf-img-convert/pdf-img-convert.js:1
import fetch from 'node-fetch';
^^^^^^
SyntaxError: Cannot use import statement outside a module
at wrapSafe (node:internal/modules/cjs/loader:1281:20)
at Module._compile (node:internal/modules/cjs/loader:1321:27)
at Module._extensions..js (node:internal/modules/cjs/loader:1416:10)
at Module.load (node:internal/modules/cjs/loader:1208:32)
at Module._load (node:internal/modules/cjs/loader:1024:12)
at cjsLoader (node:internal/modules/esm/translators:348:17)
at ModuleWrap.<anonymous> (node:internal/modules/esm/translators:297:7)
at ModuleJob.run (node:internal/modules/esm/module_job:222:25)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async ModuleLoader.import (node:internal/modules/esm/loader:316:24)
at async nodeImport Answer reference from gpt 4-o
|
The error here is actually that this package is not setting itself as a esmodule in the package.json The author needs to set |
Setting Failed parsing file into parts TypeError: process.getBuiltinModule is not a function Any ideas? |
Node v20
pnpm v9.12.2
I cannot use v2 of this package due to commonjs not being supported at all anymore. Is there a way we can get support for both esm and commonjs?
Thanks for the great work!
The text was updated successfully, but these errors were encountered: