Skip to content

Failed to load source map for /node_modules/.vite/vite.js #6981

@adrienrougeron

Description

@adrienrougeron

Describe the bug

Hello,

I'm trying to build a library using Vite and an Express server (thanks to the middleware mode of Vite). I want to import that library in a project that will be a website. The server starts but then I get an error message in my console :
[vite] Failed to load source map for /node_modules/.vite/vite.js?v=76b32c54

And when I go to http://localhost:3000 I get this error :
Uncaught SyntaxError: Invalid left-hand side in assignment

I really don't understand. I tried to add sourcemap: true in the build config in vite.config.ts and sourceMap: true in the tsconfig.json but nothing changed.

I'm pretty new to Vite and not very at ease with all javascript configs, so sorry if it's a dumb error.

Reproduction

https://github.com/adrienrougeron/vitejs-sourcemap/

System Info

System:
    OS: macOS 12.1
    CPU: (8) x64 Intel(R) Core(TM) i7-4770HQ CPU @ 2.20GHz
    Memory: 583.91 MB / 16.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 17.5.0 - ~/.nvm/versions/node/v17.5.0/bin/node
    Yarn: 1.22.17 - ~/.nvm/versions/node/v17.5.0/bin/yarn
    npm: 8.5.1 - ~/.nvm/versions/node/v17.5.0/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  Browsers:
    Brave Browser: 96.1.33.106
    Chrome: 98.0.4758.102
    Safari: 15.2

Used Package Manager

npm

Logs

vite:config bundled config file loaded in 47.11ms +0ms
  vite:config using resolved config: {
  vite:config   build: {
  vite:config     target: [ 'es2019', 'edge88', 'firefox78', 'chrome87', 'safari13.1' ],
  vite:config     polyfillModulePreload: true,
  vite:config     outDir: 'dist',
  vite:config     assetsDir: 'assets',
  vite:config     assetsInlineLimit: 4096,
  vite:config     cssCodeSplit: false,
  vite:config     cssTarget: [ 'es2019', 'edge88', 'firefox78', 'chrome87', 'safari13.1' ],
  vite:config     sourcemap: false,
  vite:config     rollupOptions: { plugins: [Array] },
  vite:config     minify: 'esbuild',
  vite:config     terserOptions: {},
  vite:config     write: true,
  vite:config     emptyOutDir: null,
  vite:config     manifest: false,
  vite:config     lib: {
  vite:config       entry: '/Users/adrien/Alphaby/vitejs-sourcemap/testpackage/src/index.ts',
  vite:config       name: 'TestPackage',
  vite:config       fileName: [Function: fileName]
  vite:config     },
  vite:config     ssr: false,
  vite:config     ssrManifest: false,
  vite:config     reportCompressedSize: true,
  vite:config     chunkSizeWarningLimit: 500,
  vite:config     watch: null,
  vite:config     commonjsOptions: { include: [Array], extensions: [Array] },
  vite:config     dynamicImportVarsOptions: { warnOnError: true, exclude: [Array] }
  vite:config   },
  vite:config   configFile: '/Users/adrien/Alphaby/vitejs-sourcemap/testpackage/vite.config.ts',
  vite:config   configFileDependencies: [ 'vite.config.ts' ],
  vite:config   inlineConfig: {
  vite:config     root: undefined,
  vite:config     base: undefined,
  vite:config     mode: undefined,
  vite:config     configFile: undefined,
  vite:config     logLevel: undefined,
  vite:config     clearScreen: undefined,
  vite:config     build: {}
  vite:config   },
  vite:config   root: '/Users/adrien/Alphaby/vitejs-sourcemap/testpackage',
  vite:config   base: '/',
  vite:config   resolve: { dedupe: undefined, alias: [ [Object], [Object] ] },
  vite:config   publicDir: '/Users/adrien/Alphaby/vitejs-sourcemap/testpackage/public',
  vite:config   cacheDir: '/Users/adrien/Alphaby/vitejs-sourcemap/testpackage/node_modules/.vite',
  vite:config   command: 'build',
  vite:config   mode: 'production',
  vite:config   isProduction: true,
  vite:config   plugins: [
  vite:config     'alias',
  vite:config     'vite:modulepreload-polyfill',
  vite:config     'vite:resolve',
  vite:config     'vite:html-inline-proxy',
  vite:config     'vite:css',
  vite:config     'vite:esbuild',
  vite:config     'vite:json',
  vite:config     'vite:wasm',
  vite:config     'vite:worker',
  vite:config     'vite:worker-import-meta-url',
  vite:config     'vite:asset',
  vite:config     'vite:define',
  vite:config     'vite:css-post',
  vite:config     'vite:watch-package-data',
  vite:config     'vite:build-html',
  vite:config     'commonjs',
  vite:config     'vite:data-uri',
  vite:config     'rollup-plugin-dynamic-import-variables',
  vite:config     'vite:asset-import-meta-url',
  vite:config     'auto-external',
  vite:config     'vite:build-import-analysis',
  vite:config     'vite:esbuild-transpile',
  vite:config     'vite:terser',
  vite:config     'vite:reporter',
  vite:config     'vite:load-fallback'
  vite:config   ],
  vite:config   server: {
  vite:config     preTransformRequests: true,
  vite:config     fs: { strict: true, allow: [Array], deny: [Array] }
  vite:config   },
  vite:config   preview: {
  vite:config     port: undefined,
  vite:config     strictPort: undefined,
  vite:config     host: undefined,
  vite:config     https: undefined,
  vite:config     open: undefined,
  vite:config     proxy: undefined,
  vite:config     cors: undefined,
  vite:config     headers: undefined
  vite:config   },
  vite:config   env: { BASE_URL: '/', MODE: 'production', DEV: false, PROD: true },
  vite:config   assetsInclude: [Function: assetsInclude],
  vite:config   logger: {
  vite:config     hasWarned: false,
  vite:config     info: [Function: info],
  vite:config     warn: [Function: warn],
  vite:config     warnOnce: [Function: warnOnce],
  vite:config     error: [Function: error],
  vite:config     clearScreen: [Function: clearScreen],
  vite:config     hasErrorLogged: [Function: hasErrorLogged]
  vite:config   },
  vite:config   packageCache: Map(0) { set: [Function (anonymous)] },
  vite:config   createResolver: [Function: createResolver],
  vite:config   optimizeDeps: {
  vite:config     esbuildOptions: { keepNames: undefined, preserveSymlinks: undefined }
  vite:config   },
  vite:config   worker: {
  vite:config     format: 'iife',
  vite:config     plugins: [
  vite:config       [Object], [Object], [Object],
  vite:config       [Object], [Object], [Object],
  vite:config       [Object], [Object], [Object],
  vite:config       [Object], [Object], [Object],
  vite:config       [Object], [Object], [Object],
  vite:config       [Object], [Object], [Object],
  vite:config       [Object], [Object], [Object],
  vite:config       [Object], [Object], [Object],
  vite:config       [Object]
  vite:config     ],
  vite:config     rollupOptions: {}
  vite:config   }
  vite:config } +6ms
vite v2.8.4 building for production...
✓ 4 modules transformed.
dist/index.es.js   1.82 KiB / gzip: 0.72 KiB
No name was provided for external module 'express' in output.globals – guessing 'express'
No name was provided for external module 'vite' in output.globals – guessing 'vite'
No name was provided for external module '@vitejs/plugin-react' in output.globals – guessing 'react'
No name was provided for external module 'iron-session' in output.globals – guessing 'ironSession$1'
No name was provided for external module 'react' in output.globals – guessing 'React'
No name was provided for external module 'react-router-dom' in output.globals – guessing 'reactRouterDom'
dist/index.umd.js   1.59 KiB / gzip: 0.79 KiB
✨  Done in 0.71s.

Validations

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions