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

vite build failed #9604

Closed
7 tasks done
ianzone opened this issue Aug 9, 2022 · 3 comments
Closed
7 tasks done

vite build failed #9604

ianzone opened this issue Aug 9, 2022 · 3 comments

Comments

@ianzone
Copy link

ianzone commented Aug 9, 2022

Describe the bug

❯ pnpm run build

> react@0.0.0 build /home/ian/templates/react
> tsc && vite build

vite v3.0.5 building for production...
✓ 19 modules transformed.
Unexpected token (Note that you need plugins to import files that are not JavaScript)
file: /home/ian/templates/react/src/pages/MyPage.tsx:29:11
27:         <p>
28:           import.meta.env:
29:           {JSON.stringify(import.meta.env)}
               ^
30:         </p>
31:       </div>
error during build:
Error: Unexpected token (Note that you need plugins to import files that are not JavaScript)
    at error (file:///home/ian/templates/react/node_modules/.pnpm/rollup@2.77.2/node_modules/rollup/dist/es/shared/rollup.js:1858:30)
    at Module.error (file:///home/ian/templates/react/node_modules/.pnpm/rollup@2.77.2/node_modules/rollup/dist/es/shared/rollup.js:12412:16)
    at Module.tryParse (file:///home/ian/templates/react/node_modules/.pnpm/rollup@2.77.2/node_modules/rollup/dist/es/shared/rollup.js:12789:25)
    at Module.setSource (file:///home/ian/templates/react/node_modules/.pnpm/rollup@2.77.2/node_modules/rollup/dist/es/shared/rollup.js:12694:24)
    at ModuleLoader.addModuleSource (file:///home/ian/templates/react/node_modules/.pnpm/rollup@2.77.2/node_modules/rollup/dist/es/shared/rollup.js:22136:20)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
 ELIFECYCLE  Command failed with exit code 1.

Reproduction

https://github.com/ianzone/react-template

System Info

System:
    OS: Linux 5.10 Ubuntu 20.04.4 LTS (Focal Fossa)
    CPU: (8) x64 Intel(R) Core(TM) i5-8250U CPU @ 1.60GHz
    Memory: 11.87 GB / 12.36 GB
    Container: Yes
    Shell: 5.8 - /usr/bin/zsh
  Binaries:
    Node: 18.7.0 - /home/linuxbrew/.linuxbrew/bin/node
    Yarn: 1.22.19 - /usr/bin/yarn
    npm: 8.15.0 - /home/linuxbrew/.linuxbrew/bin/npm
  npmPackages:
    @vitejs/plugin-react: ^2.0.0 => 2.0.0
    vite: ^3.0.5 => 3.0.5

Used Package Manager

pnpm

Logs

No response

Validations

@BTBMan
Copy link

BTBMan commented Aug 10, 2022

I realized it caused by import.meta.env text, remove or comment out will works

@ianzone
Copy link
Author

ianzone commented Aug 10, 2022

I realized it caused by import.meta.env text, remove or comment out will works

yes, it works, but it's weird that this string would cause the error.

@ianzone ianzone closed this as completed Aug 10, 2022
@BTBMan
Copy link

BTBMan commented Aug 10, 2022

#8663 Here is an issue about this.

@github-actions github-actions bot locked and limited conversation to collaborators Aug 28, 2022
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