Search code examples
vitequasar

Quasar / Vite Failed to resolve entry for package "fs". The package may have incorrect main/module/exports specified in its package.json


I get this error when I try quasar dev:

[ERROR] [plugin vite:dep-pre-bundle] Failed to resolve entry for package "fs". The package may have incorrect main/module/exports specified in its package.json: Failed to resolve entry for package "fs". The package may have incorrect main/module/exports specified in its package.json.


Solution

  • While looking on the net I found this link with the solution: here

    The solution for quasar vite is to add this part in quasar.config.js

            extendViteConf(viteConf, { isServer, isClient }) {
            // do something with viteConf... change it in-place
            viteConf.resolve = {
              alias: {
                ...viteConf.resolve.alias, // that's important we want to keep the alias set by quasar team
                fs: require.resolve('rollup-plugin-node-builtins'),
                child_process: require.resolve('rollup-plugin-node-builtins'),
              },
            };
          },
    

    To save you the trouble to search during hours.