[adapter-node] Cannot use import statement outside a module
See original GitHub issueDescribe the bug
In local, the build
with the node adapter works perfectly but when deploying it in Plesk I’ve got the message :
import { assetsMiddleware, kitMiddleware, prerenderedMiddleware } from "./middlewares.mjs";
^^^^^^
SyntaxError: Cannot use import statement outside a module
at Object.compileFunction (node:vm:352:18)
at wrapSafe (node:internal/modules/cjs/loader:1031:15)
at Module._compile (node:internal/modules/cjs/loader:1065:27)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:79:12)
at node:internal/main/run_main_module:17:47
Reproduction
Don’t know what to give to you in order to reproduce that.
Logs
No response
System Info
System:
OS: Linux 5.4 Ubuntu 20.04.3 LTS (Focal Fossa)
CPU: (4) x64 Intel(R) Xeon(R) Gold 6230R CPU @ 2.10GHz
Memory: 191.33 MB / 7.75 GB
Container: Yes
Shell: 5.0.17 - /bin/bash
Binaries:
Node: 16.9.1 - /usr/bin/node
npm: 7.21.1 - /usr/bin/npm
Severity
blocking all usage of SvelteKit
Additional Information
No response
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:17 (10 by maintainers)
Top Results From Across the Web
SvelteKit v1.0.0-next.146 SyntaxError: Cannot use import ...
I have the same issue when I start a new demo project. The error: Cannot use import statement outside a module in vscode....
Read more >SyntaxError: Cannot use import statement outside a ...
I got the error from your question (Cannot use import statement outside a module). Importing validator/es/lib/isEmail supposedly only imports a ...
Read more >Fix "cannot use import statement outside a module" in ...
This results in the error "Uncaught SyntaxError: cannot use import statement outside a module". If you've run into this error, it's possible ...
Read more >esm
I try to use SvelteKit which generates ESM code but it seems that ... [adapter-node] Cannot use import statement outside a module ·...
Read more >cannot use import statement outside a module - ItsJavaScript
The SyntaxError: cannot use import statement outside a module occurs if you have forgotten to add type="module" attribute while loading the ...
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 Free
Top 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
I had exactly the same issue on Plesk running Node 17.4.0, resolved by creating a
package.json
in the build output thus:And then pointing plesk towards an additional file (
index.cjs
) added to the build output thus:No problem. Makes also sense regarding the
{"type": "module"}
it brings and the error message. I added a small PR for the README.