vitejs / vite

Next generation frontend tooling. It's fast!
http://vite.dev
MIT License
68.67k stars 6.2k forks source link

Lerna monorepo Bootstrap systemlink #4754

Closed unpseudocomplique closed 3 years ago

unpseudocomplique commented 3 years ago

Describe the bug

Hi, i'm trying to add lerna to build a monorepo everything look good autocompletion in IDE work but, when i'm running vite dev server an error occur. Before using lerna everything was good.

Reproduction

Use lerna mono repo structure with a front folder for the vite app and a functions folder inside packages. Run lerna bootstrap and try to run vite dev server.

Structure: root/ package.json lerna.json front/ //vite app packages/
functions/ package.json index.ts

Everything for fine exept vite dev server after lerna bootstrap

System Info

npx: installed 1 in 4.695s

  System:
    OS: Windows 10 10.0.22000
    CPU: (8) x64 Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz
    Memory: 7.28 GB / 15.96 GB
  Binaries:
    Node: 14.17.3 - C:\nodejs\node.EXE
    Yarn: 1.22.10 - C:\nodejs\yarn.CMD
    npm: 6.14.13 - C:\nodejs\npm.CMD
  Browsers:
    Chrome: 92.0.4515.159
    Edge: Spartan (44.22000.120.0), Chromium (92.0.902.78), ChromiumDev (94.0.982.2)
    Internet Explorer: 11.0.22000.120

Used Package Manager

yarn

Logs

PS C:\Users\Travail\Documents\bestconsultant\bestconsultantv2\front> yarn dev
yarn run v1.22.10
warning package.json: No license field
$ vite --host --force --debug
  vite:config bundled config file loaded in 504ms +0ms
  vite:config using resolved config: {
  vite:config   plugins: [
  vite:config     'vite:pre-alias',
  vite:config     'alias',
  vite:config     'svg-loader',
  vite:config     'vite:modulepreload-polyfill',
  vite:config     'vite:resolve',
  vite:config     'vite:html',
  vite:config     'vite:css',
  vite:config     'vite:esbuild',
  vite:config     'vite:json',
  vite:config     'vite:wasm',
  vite:config     'vite:worker',
  vite:config     'vite:asset',
  vite:config     'vite:vue',
  vite:config     'vite:define',
  vite:config     'vite:css-post',
  vite:config     'vite:client-inject',
  vite:config     'vite:import-analysis'
  vite:config   ],
  vite:config   resolve: { dedupe: undefined, alias: [ [Object], [Object], [Object] ] },
  vite:config   server: {
  vite:config     host: true,
  vite:config     force: true,
  vite:config     fs: { strict: undefined, allow: [Array] }
  vite:config   },
  vite:config   define: { __VUE_OPTIONS_API__: true, __VUE_PROD_DEVTOOLS__: false },
  vite:config   ssr: { external: [ 'vue', '@vue/server-renderer' ] },
  vite:config   configFile: 'C:/Users/Travail/Documents/bestconsultant/bestconsultantv2/front/vite.config.js',
  vite:config   configFileDependencies: [ 'vite.config.js' ],
  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     server: { host: true, force: true, fs: [Object] }
  vite:config   },
  vite:config   root: 'C:/Users/Travail/Documents/bestconsultant/bestconsultantv2/front',
  vite:config   base: '/',
  vite:config   publicDir: 'C:\\Users\\Travail\\Documents\\bestconsultant\\bestconsultantv2\\front\\public',
  vite:config   cacheDir: 'C:\\Users\\Travail\\Documents\\bestconsultant\\bestconsultantv2\\front\\node_modules\\.vite',  vite:config   command: 'serve',
  vite:config   mode: 'development',
  vite:config   isProduction: false,
  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: true,
  vite:config     sourcemap: false,
  vite:config     rollupOptions: {},
  vite:config     commonjsOptions: { include: [Array], extensions: [Array] },
  vite:config     dynamicImportVarsOptions: { warnOnError: true, exclude: [Array] },
  vite:config     minify: 'terser',
  vite:config     terserOptions: {},
  vite:config     write: true,
  vite:config     emptyOutDir: null,
  vite:config     manifest: false,
  vite:config     lib: false,
  vite:config     ssr: false,
  vite:config     ssrManifest: false,
  vite:config     brotliSize: true,
  vite:config     chunkSizeWarningLimit: 500,
  vite:config     watch: null
  vite:config   },
  vite:config   env: {
  vite:config     VITE_API_PROTOCOL: 'http://',
  vite:config     VITE_API_DOMAIN: '192.168.1.34',
  vite:config     VITE_API_PORT: ':9000',
  vite:config     BASE_URL: '/',
  vite:config     MODE: 'development',
  vite:config     DEV: true,
  vite:config     PROD: false
  vite:config   },
  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   createResolver: [Function: createResolver],
  vite:config   optimizeDeps: { esbuildOptions: { keepNames: undefined } }
  vite:config } +7ms
  vite:deps Crawling dependencies using entries:
  vite:deps   C:/Users/Travail/Documents/bestconsultant/bestconsultantv2/front/index.html +0ms
  vite:resolve 0ms   /src/main.js -> C:/Users/Travail/Documents/bestconsultant/bestconsultantv2/front/src/main.js +0ms
  vite:resolve 3ms   vue -> C:/Users/Travail/Documents/bestconsultant/bestconsultantv2/node_modules/vue/dist/vue.runtime.esm-bundler.js +5ms
  vite:resolve 1ms   ./App.vue -> C:/Users/Travail/Documents/bestconsultant/bestconsultantv2/front/src/App.vue +2ms
  vite:resolve 4ms   C:\src/store -> null +4ms
  vite:resolve 4ms   @/store -> C:\src/store +0ms
  vite:resolve 3ms   C:\src/router -> null +4ms
  vite:resolve 3ms   @/router -> C:\src/router +0ms
  vite:resolve 2ms   v-calendar -> C:/Users/Travail/Documents/bestconsultant/bestconsultantv2/node_modules/v-calendar/lib/esm/index.js +4ms
  vite:resolve 2ms   @fortawesome/fontawesome-svg-core -> C:/Users/Travail/Documents/bestconsultant/bestconsultantv2/node_modules/@fortawesome/fontawesome-svg-core/index.es.js +31ms
  vite:resolve 2ms   C:\src/translation -> null +58ms
  vite:resolve 3ms   @/translation -> C:\src/translation +1ms
  vite:resolve 2ms   animate.css -> C:/Users/Travail/Documents/bestconsultant/bestconsultantv2/node_modules/animate.css/animate.css +2ms
  vite:resolve 2ms   @fortawesome/pro-regular-svg-icons -> C:/Users/Travail/Documents/bestconsultant/bestconsultantv2/node_modules/@fortawesome/pro-regular-svg-icons/index.es.js +3ms
  vite:resolve 2ms   @fortawesome/pro-duotone-svg-icons -> C:/Users/Travail/Documents/bestconsultant/bestconsultantv2/node_modules/@fortawesome/pro-duotone-svg-icons/index.es.js +3ms
  vite:resolve 1ms   @fortawesome/vue-fontawesome -> C:/Users/Travail/Documents/bestconsultant/bestconsultantv2/node_modules/@fortawesome/vue-fontawesome/index.es.js +2ms
  vite:resolve 3ms   C:\src/views/login/Login.vue -> null +8ms
  vite:resolve 3ms   @/views/login/Login.vue -> C:\src/views/login/Login.vue +0ms
  vite:resolve 2ms   vuex -> C:/Users/Travail/Documents/bestconsultant/bestconsultantv2/node_modules/vuex/dist/vuex.esm-bundler.js +4ms
  vite:resolve 3ms   C:\src/components/navigationDrawer/navigationDrawer.vue -> null +5ms
  vite:resolve 3ms   @/components/navigationDrawer/navigationDrawer.vue -> C:\src/components/navigationDrawer/navigationDrawer.vue +0ms
  vite:resolve 7ms   C:\src/services/application -> null +19ms
  vite:resolve 7ms   @/services/application -> C:\src/services/application +0ms
 > ../node_modules/vite/dist/node/chunks/dep-972722fa.js:51530:38: error: [plugin: vite:dep-scan] ENOENT: no such file or directory, open 'C:/src/views/login/Login.vue'
    51530 │                 let raw = fs__default.readFileSync(path, 'utf-8');
          ╵                                       ^
    at Object.openSync (fs.js:498:3)
    at Object.readFileSync (fs.js:394:35)
    at C:\Users\Travail\Documents\bestconsultant\bestconsultantv2\node_modules\vite\dist\node\chunks\dep-972722fa.js:51530:39
    at callback (C:\Users\Travail\Documents\bestconsultant\bestconsultantv2\node_modules\esbuild\lib\main.js:869:34)
    at handleRequest (C:\Users\Travail\Documents\bestconsultant\bestconsultantv2\node_modules\esbuild\lib\main.js:652:36)
    at handleIncomingPacket (C:\Users\Travail\Documents\bestconsultant\bestconsultantv2\node_modules\esbuild\lib\main.js:699:7)
    at Socket.readFromStdout (C:\Users\Travail\Documents\bestconsultant\bestconsultantv2\node_modules\esbuild\lib\main.js:576:7)
    at Socket.emit (events.js:375:28)
    at Socket.emit (domain.js:470:12)
    at addChunk (internal/streams/readable.js:290:12)

   ../node_modules/vite/dist/node/chunks/dep-972722fa.js:51529:18: note: This error came from the "onLoad" callback registered here
    51529 │             build.onLoad({ filter: htmlTypesRE, namespace: 'html' }, async ({ path }) => {
          ╵                   ~~~~~~
    at setup (C:\Users\Travail\Documents\bestconsultant\bestconsultantv2\node_modules\vite\dist\node\chunks\dep-972722fa.js:51529:19)
    at handlePlugins (C:\Users\Travail\Documents\bestconsultant\bestconsultantv2\node_modules\esbuild\lib\main.js:736:23)
    at Object.buildOrServe (C:\Users\Travail\Documents\bestconsultant\bestconsultantv2\node_modules\esbuild\lib\main.js:1024:7)
    at C:\Users\Travail\Documents\bestconsultant\bestconsultantv2\node_modules\esbuild\lib\main.js:1756:17
    at new Promise (<anonymous>)
    at Object.build (C:\Users\Travail\Documents\bestconsultant\bestconsultantv2\node_modules\esbuild\lib\main.js:1755:14)
    at Object.build (C:\Users\Travail\Documents\bestconsultant\bestconsultantv2\node_modules\esbuild\lib\main.js:1631:51)
    at C:\Users\Travail\Documents\bestconsultant\bestconsultantv2\node_modules\vite\dist\node\chunks\dep-972722fa.js:51456:54
    at Array.map (<anonymous>)

   html:C:/Users/Travail/Documents/bestconsultant/bestconsultantv2/front/src/App.vue:3:18: note: The plugin "vite:dep-scan" was triggered by this import
        3 │ import Login from '@/views/login/Login.vue';
          ╵                   ~~~~~~~~~~~~~~~~~~~~~~~~~

 > ../node_modules/vite/dist/node/chunks/dep-972722fa.js:51530:38: error: [plugin: vite:dep-scan] ENOENT: no such file or directory, open 'C:/src/components/navigationDrawer/navigationDrawer.vue'
    51530 │                 let raw = fs__default.readFileSync(path, 'utf-8');
          ╵                                       ^
    at Object.openSync (fs.js:498:3)
    at Object.readFileSync (fs.js:394:35)
    at C:\Users\Travail\Documents\bestconsultant\bestconsultantv2\node_modules\vite\dist\node\chunks\dep-972722fa.js:51530:39
    at callback (C:\Users\Travail\Documents\bestconsultant\bestconsultantv2\node_modules\esbuild\lib\main.js:869:34)
    at handleRequest (C:\Users\Travail\Documents\bestconsultant\bestconsultantv2\node_modules\esbuild\lib\main.js:652:36)
    at handleIncomingPacket (C:\Users\Travail\Documents\bestconsultant\bestconsultantv2\node_modules\esbuild\lib\main.js:699:7)
    at Socket.readFromStdout (C:\Users\Travail\Documents\bestconsultant\bestconsultantv2\node_modules\esbuild\lib\main.js:576:7)
    at Socket.emit (events.js:375:28)
    at Socket.emit (domain.js:470:12)
    at addChunk (internal/streams/readable.js:290:12)

   ../node_modules/vite/dist/node/chunks/dep-972722fa.js:51529:18: note: This error came from the "onLoad" callback registered here
    51529 │             build.onLoad({ filter: htmlTypesRE, namespace: 'html' }, async ({ path }) => {
          ╵                   ~~~~~~
    at setup (C:\Users\Travail\Documents\bestconsultant\bestconsultantv2\node_modules\vite\dist\node\chunks\dep-972722fa.js:51529:19)
    at handlePlugins (C:\Users\Travail\Documents\bestconsultant\bestconsultantv2\node_modules\esbuild\lib\main.js:736:23)
    at Object.buildOrServe (C:\Users\Travail\Documents\bestconsultant\bestconsultantv2\node_modules\esbuild\lib\main.js:1024:7)
    at C:\Users\Travail\Documents\bestconsultant\bestconsultantv2\node_modules\esbuild\lib\main.js:1756:17
    at new Promise (<anonymous>)
    at Object.build (C:\Users\Travail\Documents\bestconsultant\bestconsultantv2\node_modules\esbuild\lib\main.js:1755:14)
    at Object.build (C:\Users\Travail\Documents\bestconsultant\bestconsultantv2\node_modules\esbuild\lib\main.js:1631:51)
    at C:\Users\Travail\Documents\bestconsultant\bestconsultantv2\node_modules\vite\dist\node\chunks\dep-972722fa.js:51456:54
    at Array.map (<anonymous>)

   html:C:/Users/Travail/Documents/bestconsultant/bestconsultantv2/front/src/App.vue:5:29: note: The plugin "vite:dep-scan" was triggered by this import
        5 │ import navigationDrawer from '@/components/navigationDrawer/navigationDrawer.vue';
          ╵                              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

error when starting dev server:
Error: Build failed with 2 errors:
../node_modules/vite/dist/node/chunks/dep-972722fa.js:51530:38: error: [plugin: vite:dep-scan] ENOENT: no such file or directory, open 'C:/src/components/navigationDrawer/navigationDrawer.vue'
../node_modules/vite/dist/node/chunks/dep-972722fa.js:51530:38: error: [plugin: vite:dep-scan] ENOENT: no such file or directory, open 'C:/src/views/login/Login.vue'
    at failureErrorWithLog (C:\Users\Travail\Documents\bestconsultant\bestconsultantv2\node_modules\esbuild\lib\main.js:1451:15)
    at C:\Users\Travail\Documents\bestconsultant\bestconsultantv2\node_modules\esbuild\lib\main.js:1131:28
    at runOnEndCallbacks (C:\Users\Travail\Documents\bestconsultant\bestconsultantv2\node_modules\esbuild\lib\main.js:921:63)
    at buildResponseToResult (C:\Users\Travail\Documents\bestconsultant\bestconsultantv2\node_modules\esbuild\lib\main.js:1129:7)
    at C:\Users\Travail\Documents\bestconsultant\bestconsultantv2\node_modules\esbuild\lib\main.js:1238:14
    at C:\Users\Travail\Documents\bestconsultant\bestconsultantv2\node_modules\esbuild\lib\main.js:609:9
    at handleIncomingPacket (C:\Users\Travail\Documents\bestconsultant\bestconsultantv2\node_modules\esbuild\lib\main.js:706:9)
    at Socket.readFromStdout (C:\Users\Travail\Documents\bestconsultant\bestconsultantv2\node_modules\esbuild\lib\main.js:576:7)
    at Socket.emit (events.js:375:28)
    at Socket.emit (domain.js:470:12)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Validations

unpseudocomplique commented 3 years ago

fixed the issue by using relative path in my alias definition.

        alias: {
            '@': path.resolve(__dirname, './src'),
        },