Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pre-bundling cannot resolve dependency (but dependency exists) #5766

Closed
7 tasks done
nicholasjpanella opened this issue Nov 20, 2021 · 1 comment
Closed
7 tasks done

Comments

@nicholasjpanella
Copy link

Describe the bug

NOTE: our system has a 'copy-cat' folder for a network drive as a sort of backup mechanism, this replicates all files in the drive to a folder in the C drive.

When I run vite build everything compiles fine, BUT when I just run vite the pre-bundling fails.

Architecture is using lerna, all dependencies are hoisted to the top level of the project

Reproduction

NOTE: our system has a 'copy-cat' folder for a network drive as a sort of backup mechanism, this replicates all files in the drive to a folder in the C drive.

lerna structure

node_modules
packages
test-vite-project
examples
index.tsx
index.scss
index.html
src\index.ts
vite.config.js
package.json
tsconfig.json
package.json
tsconfig.json

vite.config.js

const path = require("path");
const react = require("@vitejs/plugin-react");
const { defineConfig } = require("vite");

module.exports = defineConfig({
    root: "examples",
    plugins: [react()],
})

exampes/index.html

<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <meta http-equiv="cache-control" content="no-cache">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <title>Examples</title>
    </head>
    <body>
        <h1 style="margin-bottom: 50px;">Examples</h1>
        <div id="app"></div>
        <script type="module" src="./index.tsx"></script>
    </body>
</html>

exampes/index.tsx

import React from 'react';
import ReactDOM from 'react-dom';
import './index.scss';

const App = () => {
    return (
        <div>
            <p>Hello</p>
        </div>
    );
};

ReactDOM.render(
    <React.StrictMode>
        <App />
    </React.StrictMode>,
    document.getElementById('app')
);

System Info

$ npx envinfo --system --npmPackages '{vite,@vitejs/*}' --binaries --browsers
npx: installed 1 in 2.731s

  System:
    OS: Windows 7 6.1.7601
    CPU: (8) x64 Intel(R) Xeon(R) CPU E3-1585L v5 @ 3.00GHz
    Memory: 35.05 GB / 63.87 GB
  Binaries:
    Node: 12.22.6 - I:\xx\tools\nodejs12\latest\node.EXE
    npm: 6.12.0 - I:\xx\.npm12\npm.CMD
  Browsers:
    Chrome: 92.0.4515.107
    Internet Explorer: 11.0.9600.20120

Used Package Manager

npm

Logs

xxxxxxx@xxxxxx I:\xx\projects\xxx-xxxxx\xxx\packages\test-vite-project
$ npm start -- --debug

> @xxxxxxxx/xxxxxxxx@1.0.0 start I:\xx\projects\xxx-xxxxx\xxx\packages\test-vite-project
> vite "--debug"

  vite:config cjs config loaded in 210.97ms +0ms
  vite:config using resolved config: {
  vite:config   root: 'I:/xx/projects/xxx-xxxxx/xxx/packages/test-vite-project/examples',
  vite:config   plugins: [
  vite:config     'vite:pre-alias',
  vite:config     'alias',
  vite:config     'vite:react-babel',
  vite:config     'vite:react-refresh',
  vite:config     'vite:react-jsx',
  vite:config     'vite:modulepreload-polyfill',
  vite:config     'vite:resolve',
  vite:config     'vite:html-inline-script-proxy',
  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:define',
  vite:config     'vite:css-post',
  vite:config     'vite:client-inject',
  vite:config     'vite:import-analysis'
  vite:config   ],
  vite:config   optimizeDeps: {
  vite:config     include: [ 'react/jsx-dev-runtime' ],
  vite:config     esbuildOptions: { keepNames: undefined, preserveSymlinks: undefined }
  vite:config   },
  vite:config   server: { fs: { strict: undefined, allow: [Array] } },
  vite:config   resolve: { dedupe: [ 'react', 'react-dom' ], alias: [ [Object], [Object] ] },
  vite:config   configFile: 'I:/ds/projects/app-common/app/packages/test-vite-project/vite.config.js',
  vite:config   configFileDependencies: [],
  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: { fs: [Object] }
  vite:config   },
  vite:config   base: '/',
  vite:config   publicDir: 'I:\\xx\\projects\\xxx-xxxxxx\\xxx\\packages\\test-vite-project\\examples\\public',
  vite:config   cacheDir: 'I:\\xx\\projects\\xxx-xxxxxx\\xxx\\packages\\test-vite-project\\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     cssTarget: [ 'es2019', 'edge88', 'firefox78', 'chrome87', 'safari13.1' ],
  vite:config     sourcemap: false,
  vite:config     rollupOptions: {},
  vite:config     minify: 'esbuild',
  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     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   env: { BASE_URL: '/', MODE: 'development', DEV: true, PROD: false },
  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 } +15ms
  vite:deps Crawling dependencies using entries:
  vite:deps   I:/xx/projects/xxx-xxxxx/xxx/packages/test-vite-project/examples/index.html +0ms
  vite:resolve 1.00ms ./index.tsx -> I:/xx/projects/xxx-xxxxx/xxx/packages/test-vite-project/examples/index.tsx +0ms
  vite:resolve 6.74ms react -> C:/Users/XXXXXXX/Scratch/xx/projects/xxx-xxxxx/xxx/node_modules/react/index.js +9ms
  vite:resolve 5.13ms react-dom -> C:/Users/XXXXXX/Scratch/xx/projects/xxx-xxxxx/xxx/node_modules/react-dom/index.js +6ms
  vite:deps Scan completed in 243.29ms: {
  react: 'C:/Users/XXXXXXX/Scratch/xx/projects/xxx-xxxxx/xxx/node_modules/react/index.js',
  'react-dom': 'C:/Users/XXXXXXX/Scratch/xx/projects/xxx-xxxxx/xxx//node_modules/react-dom/index.js'
} +235ms
  vite:resolve 1.38ms react/jsx-dev-runtime -> C:/Users/XXXXXXX/Scratch/xx/projects/xxx-xxxxx/xxx/node_modules/react/jsx-dev-runtime.js +0ms
Pre-bundling dependencies:
  react
  react-dom
  react/jsx-dev-runtime
(this will be run only when your dependencies or config have changed)
 > dep:react:1:23: error: Could not resolve "./C:/Users/XXXXXX/Scratch/xx/projects/xxx-xxxxxx/xxx/node_modules/react/index.js"
    1 │ export default require("./C:/Users/XXXXXX/Scratch/xx/projects/xxx-xxxxxx/xxx/node_modules/react/index.js");~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

 > dep:react_jsx-dev-runtime:1:23: error: Could not resolve "./C:/Users/XXXXXX/Scratch/xx/projects/xxx-xxxxxx/xxx/node_modules/react/jsx-dev-runtime.js"
    1 │ export default require("./C:/Users/XXXXXXX/Scratch/xx/projects/xxx-xxxxx/xxx/react/jsx-dev-runtime.js");~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

 > dep:react-dom:1:23: error: Could not resolve "./C:/Users/XXXXXX/Scratch/xx/projects/xxx-xxxxxx/xxx/node_modules/react-dom/index.js"
    1 │ export default require("./C:/Users/XXXXXX/Scratch/xx/projects/xxx-xxxxxx/xxx/node_modules/react-dom/index.js");~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

error when starting dev server:
Error: Build failed with 3 errors:
dep:react:1:23: error: Could not resolve "./C:/Users/XXXXXX/Scratch/xx/projects/xxx-xxxxxx/xxx/node_modules/react/index.js"
dep:react-dom:1:23: error: Could not resolve "./C:/Users/XXXXXX/Scratch/xx/projects/xxx-xxxxxx/xxx/node_modules/react-dom/index.js"
dep:react_jsx-dev-runtime:1:23: error: Could not resolve "./C:/Users/XXXXXX/Scratch/xx/projects/xxx-xxxxxx/xxx/node_modules/react/jsx-dev-runtime.js"
    at failureErrorWithLog (I:\xx\projects\xxx-xxxxxx\xxx\node_modules\esbuild\lib\main.js:1493:15)
    at I:\xx\projects\xxx-xxxxxx\xxx\node_modules\esbuild\lib\main.js:1151:28
    at runOnEndCallbacks (I:\xx\projects\xxx-xxxxxx\xxx\node_modules\esbuild\lib\main.js:941:63)
    at buildResponseToResult (I:\xx\projects\xxx-xxxxxx\xxx\node_modules\esbuild\lib\main.js:1149:7)
    at I:\xx\projects\xxx-xxxxxx\xxx\node_modules\esbuild\lib\main.js:1258:14
    at I:\xx\projects\xxx-xxxxxx\xxx\node_modules\esbuild\lib\main.js:629:9
    at handleIncomingPacket (I:\xx\projects\xxx-xxxxxx\xxx\node_modules\esbuild\lib\main.js:726:9)
    at Socket.readFromStdout (I:\xx\projects\xxx-xxxxxx\xxx\node_modules\esbuild\lib\main.js:596:7)
    at Socket.emit (events.js:314:20)
    at addChunk (_stream_readable.js:297:12)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @xxxxxx/test-vite-project@1.0.0 start: `vite "--debug"`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @xxxxxx/test-vite-project@1.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\XXXXXX\AppData\Roaming\npm-cache\_logs\2021-11-20T00_29_27_696Z-debug.log

Validations

@bluwy
Copy link
Member

bluwy commented Nov 20, 2021

Duplicate of #4635

@bluwy bluwy closed this as completed Nov 26, 2021
@github-actions github-actions bot locked and limited conversation to collaborators Dec 11, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants