cm-chessboard
cm-chessboard copied to clipboard
Unable to build with Vite 3
(node:94053) Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension.
(Use node --trace-warnings ...
to show where the warning was created)
/Users/zeti/Platform/games/node_modules/.pnpm/[email protected]/node_modules/cm-chessboard/src/cm-chessboard/Chessboard.js:7
import {ChessboardState} from "./model/ChessboardState.js"
^^^^^^
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.
The repo: https://github.com/ZetiAi/games
When doing pnpm build
This worked on Vite 2.
This seems to be more of a Vite 3 issue, so you should report this to support there. 🤷♂️
In my Vite 3 project I am able to to dev/build no problem. Using Vite 3.0.5
In my Vite 3 project I am able to to dev/build no problem. Using Vite 3.0.5
Could you share your repo? My impression was the current packaging wasn't compatible with Node.js. And that all the files were being treated as CommonJS unless "type": "module" is set in package.json or the files end with .mjs
hmm okay, if I add "type": "module" in the package.json file, the error goes away.
In the package.json of cm-chessboard? This could be easy added.
In the package.json of cm-chessboard? This could be easy added.
yeah, it seems the issue is not vite 3 but Node 16.15.0. That would be great if you could add! 👍
Fixed with version 5.0.1
@shaack You're the man! Thank you!