I'm getting this build error with Nuxt3.0 stable.
nuxi dev
works fine.
I get the following error when I run nuxi build
.
ERROR 'fileURLToPath' is not exported by __vite-browser-external, imported by node_modules/local-pkg/dist/shared.mjs 13:57:26
file: /node_modules/local-pkg/dist/shared.mjs:41:9
39: import path from "path";
40: import fs, { promises as fsPromises } from "fs";
41: import { fileURLToPath } from "url";
^
42:
43: // node_modules/.pnpm/yocto-queue@1.0.0/node_modules/yocto-queue/index.js
ERROR 'fileURLToPath' is not exported by __vite-browser-external, imported by node_modules/local-pkg/dist/shared.mjs 13:57:26
at error (node_modules/rollup/dist/es/shared/rollup.js:1858:30)
at Module.error (node_modules/rollup/dist/es/shared/rollup.js:12429:16)
at Module.traceVariable (node_modules/rollup/dist/es/shared/rollup.js:12788:29)
at ModuleScope.findVariable (node_modules/rollup/dist/es/shared/rollup.js:11440:39)
This is my nuxt.config.ts
export default defineNuxtConfig({
modules: ['@pinia/nuxt'],
runtimeConfig: {
},
hooks: {
'components:dirs'(dirs: any) {
dirs.push({
path: '~/components',
})
},
},
components: {
global: true,
},
nitro: {
preset: 'aws-lambda',
serveStatic: true,
},
app: {
baseURL: '/',
},
build: {
transpile: ['chart.js'],
},
typescript: {
shim: false,
strict: true,
},
vite: {
resolve: {
alias: {
'./runtimeConfig': './runtimeConfig.browser',
},
},
},
})
I tried these but build still doesn't work.
Polyfill node os module with vite/rollup.js
https://github.com/aws-amplify/amplify-js/issues/9639#issuecomment-1315152038