umbrella22 / electron-vite-template

This project is a vue3 + Vite + electron project template composed of Vite and rollup. It has the same functions as my previous electron+Vue+template project
Other
398 stars 108 forks source link

Cannot use import statement outside a module #102

Closed FifineHex closed 1 year ago

FifineHex commented 1 year ago

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 1 year ago

@umbrella22 Me too.

samo-c commented 1 year ago

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

FifineHex commented 1 year ago

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.

umbrella22 commented 1 year ago

@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