umbrella22/electron-vite-template

Cannot use import statement outside a module

FifineHex opened this issue · 4 comments

I followed the steps at readme (clone, install), but when I run yarn dev, I get the following error

C:\electron-vite-template>yarn dev
yarn run v1.22.19
$ esno .electron-vite/dev-runner.ts
(node:15388) ExperimentalWarning: Custom ESM Loaders is an experimental feature and might change at any time
(Use node --trace-warnings ... to show where the warning was created)
C:\electron-vite-template.electron-vite\dev-runner.ts:3
import electron from "electron";
^^^^^^

SyntaxError: Cannot use import statement outside a module
at internalCompileFunction (node:internal/vm:73:18)
at wrapSafe (node:internal/modules/cjs/loader:1177:20)
at Module._compile (node:internal/modules/cjs/loader:1221:27)
at Module._extensions..js (node:internal/modules/cjs/loader:1311:10)
at Module.load (node:internal/modules/cjs/loader:1115:32)
at Module._load (node:internal/modules/cjs/loader:962:12)
at ModuleWrap. (node:internal/modules/esm/translators:165:29)
at ModuleJob.run (node:internal/modules/esm/module_job:192:25)
at async CustomizedModuleLoader.import (node:internal/modules/esm/loader:246:24)
at async loadESM (node:internal/process/esm_loader:40:7)

Node.js v20.3.1
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

samo-c commented

@umbrella22 Me too.

samo-c commented

@FifineHex My problem was solved. But when I switched nodeJS from v20 back to v18, it was solved

I noticed this when I had created this issue, but in the end, I ended up using my own solution (vue + webview + c#) without depending on electron or node, I got a significant gain in performance and RAM consumption.

@samo-c Now it's working properly
@FifineHex I'm glad and envious of your ability to use C #. I hope the framework can help you next time