Open ZejusJS opened 7 months ago
I am having the same problem. I have a sveltekit application, runs fine in dev or preview mode, but the build process fails with the error as above :-
error during build:RollupError:
Unexpected character '\u{7f}'
which I tracked down to being in the Argon2 module argon2-linux-arm64-gnu module that my Lucia auth packages bring in. I get the same on 2 different runtime platforms - Arm and Intel.
See https://github.com/napi-rs/use-napi-rs-packages-with-bundlers
Still can't get it to work.
When i use the Vite example, I get another error:
ReferenceError [Error]: require is not defined in ES module scope, you can use import instead
This file is being treated as an ES module because it has a '.js' file extension and '/app/package.json' contains "type": "module". To treat it as a CommonJS script, rename it to use the '.cjs' file extension.
at file:///app/.svelte-kit/output/server/entries/endpoints/api/_server.ts.js:5:29
...
It compiles everyting. So I tried to use only ViteNodeAddonPlugin
function, but I got the same error RollupError: Unexpected character '\u{7f}'
.
Same issue. Bump.
Looks like I am facing same issue. sveltekit and Lucia. dev build is working prod build fails with same error message. Ive tried node 18 and 20. Both same error I ve tried macos and ubuntu both same error.
I am totally blocked by this and I ve got no idea how to solve this :-( If anybody has a hint, would be grately appreciated
/Users/volkerhochstein/projects/node/magic-pull/node_modules/@node-rs/argon2-darwin-arm64/argon2.darwin-arm64.node error during build: RollupError: Unexpected character '�' at getRollupError (file:///Users/volkerhochstein/projects/node/magic-pull/node_modules/rollup/dist/es/shared/parseAst.js:395:41)
"@lucia-auth/adapter-prisma": "^4.0.1",
"@prisma/client": "^5.13.0",
"@sveltejs/adapter-node": "^5.0.1",
"lucia": "^3.2.0",
"oslo": "^1.2.0",
"typescript": "^5.4.5",
"vite": "^5.2.11",
"vite-plugin-tailwind-purgecss": "0.3.3",
"@sveltejs/kit": "^2.5.7",
"@sveltejs/vite-plugin-svelte": "^3.1.0",
I've managed to get my build working, but to do it I stopped using the oslo package. I was using Argon2 from oslo to create password hashes, and I thought that was where the problem lay so I switched to bcrypt. I think what made the main difference though, was moving the bcrypt package (and my better-sqlite3 package) out of devDependcies into dependencies in my package.json :
"devDependencies": {
"@lucia-auth/adapter-sqlite": "^3.0.1",
"@skeletonlabs/skeleton": "^2.9.0",
"@skeletonlabs/tw-plugin": "^0.3.1",
"@sveltejs/adapter-auto": "^3.0.0",
"@sveltejs/adapter-node": "^5.0.1",
"@sveltejs/kit": "^2.0.0",
"@sveltejs/vite-plugin-svelte": "^3.0.0",
"@tailwindcss/forms": "^0.5.7",
"@types/better-sqlite3": "^7.6.9",
"@types/d3": "^7.4.3",
"@types/eslint": "^8.56.0",
"@types/leaflet": "^1.9.12",
"@typescript-eslint/eslint-plugin": "^7.0.0",
"@typescript-eslint/parser": "^7.0.0",
"autoprefixer": "^10.4.16",
"d3": "^7.9.0",
"eslint": "^8.56.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-svelte": "^2.35.1",
"express": "^4.19.2",
"iconify-icon": "^2.0.0",
"lucia": "^3.1.1",
"postcss": "^8.4.32",
"postcss-load-config": "^5.0.2",
"prettier": "^3.1.1",
"prettier-plugin-svelte": "^3.1.2",
"prettier-plugin-tailwindcss": "^0.5.9",
"svelte": "^4.2.7",
"svelte-check": "^3.6.0",
"tailwindcss": "^3.4.3",
"tslib": "^2.4.1",
"typescript": "^5.4.5",
"vite": "^5.0.3"
},
"type": "module",
"dependencies": {
"@types/bcrypt": "^5.0.2",
"bcrypt": "^5.1.1",
"better-sqlite3": "^9.6.0",
"dotenv": "^16.4.5",
"leaflet": "^1.9.4"
}
│ ▲ Next.js 14.2.4
│
│ Creating an optimized production build ...
│ Failed to compile.
│
│ ../../packages/api/node_modules/@node-rs/argon2-linux-x64-gnu/argon2.linux-x64-gnu.node
│ Module parse failed: Unexpected character '' (1:0)
│ You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
In my case, moving oslo
from devDependencies
to dependencies
resolved the production build issue. I had been using Argon2id
from oslo/password
in a SvelteKit project.
I'm having issue during building a SvelteKit project with napi-rs/node-rs. The issue occurs when building it in Docker image but when I build it on Vercel it's working.
I tried to use vite.config.ts from use-napi-rs-packages-with-bundlers but I'm only getting another error (SvelteKit can't use webpack).
I'm using @sveltejs/kit@^2.5.5, @node-rs/bcrypt@^1.10.1 and vite@^5.2.7. This error occurs in another dockerized SvelteKit projects aswell.
My Dockerfile is: