build fails with import statement in 3.1.6
See original GitHub issueDescribe the bug
npm run build fails to complete with v3.1.6 giving me the error “[plugin externalize-deps] Failed to resolve entry for package “fs”. The package may have incorrect main/module/exports specified in its package.json.” I resolved the problem by downgrading to Vite 3.1.4.
Reproduction
https://stackblitz.com/edit/vitejs-vite-rssden
System Info
System:
OS: macOS 12.5.1
CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
Memory: 1.03 GB / 16.00 GB
Shell: 5.8.1 - /bin/zsh
Binaries:
Node: 14.20.0 - ~/.nvm/versions/node/v14.20.0/bin/node
npm: 6.14.17 - ~/.nvm/versions/node/v14.20.0/bin/npm
npmPackages:
@vitejs/plugin-vue: ^3.1.2 => 3.1.2
vite: ^3.1.6 => 3.1.6
Used Package Manager
npm
Logs
ERROR] [plugin externalize-deps] Failed to resolve entry for package “fs”. The package may have incorrect main/module/exports specified in its package.json.
node_modules/esbuild/lib/main.js:1327:27:
1327 │ let result = await callback({
╵ ^
at packageEntryFailure (file:///Users/markbokil/dev/clinic-frx-delivery-log-ui/node_modules/vite/dist/node/chunks/dep-db16f19c.js:34841:11)
at resolvePackageEntry (file:///Users/markbokil/dev/clinic-frx-delivery-log-ui/node_modules/vite/dist/node/chunks/dep-db16f19c.js:34838:5)
at tryNodeResolve (file:///Users/markbokil/dev/clinic-frx-delivery-log-ui/node_modules/vite/dist/node/chunks/dep-db16f19c.js:34584:20)
at file:///Users/markbokil/dev/clinic-frx-delivery-log-ui/node_modules/vite/dist/node/chunks/dep-db16f19c.js:63459:44
at requestCallbacks.on-resolve (/Users/markbokil/dev/clinic-frx-delivery-log-ui/node_modules/esbuild/lib/main.js:1327:28)
at handleRequest (/Users/markbokil/dev/clinic-frx-delivery-log-ui/node_modules/esbuild/lib/main.js:697:19)
at handleIncomingPacket (/Users/markbokil/dev/clinic-frx-delivery-log-ui/node_modules/esbuild/lib/main.js:719:7)
at Socket.readFromStdout (/Users/markbokil/dev/clinic-frx-delivery-log-ui/node_modules/esbuild/lib/main.js:647:7)
at Socket.emit (events.js:400:28)
at addChunk (internal/streams/readable.js:293:12)
This error came from the “onResolve” callback registered here:
node_modules/esbuild/lib/main.js:1251:20:
1251 │ let promise = setup({
╵ ^
at setup (file:///Users/markbokil/dev/clinic-frx-delivery-log-ui/node_modules/vite/dist/node/chunks/dep-db16f19c.js:63456:27)
at handlePlugins (/Users/markbokil/dev/clinic-frx-delivery-log-ui/node_modules/esbuild/lib/main.js:1251:21)
at buildOrServeImpl (/Users/markbokil/dev/clinic-frx-delivery-log-ui/node_modules/esbuild/lib/main.js:942:5)
at Object.buildOrServe (/Users/markbokil/dev/clinic-frx-delivery-log-ui/node_modules/esbuild/lib/main.js:750:5)
at /Users/markbokil/dev/clinic-frx-delivery-log-ui/node_modules/esbuild/lib/main.js:2085:17
at new Promise (<anonymous>)
at Object.build (/Users/markbokil/dev/clinic-frx-delivery-log-ui/node_modules/esbuild/lib/main.js:2084:14)
at build (/Users/markbokil/dev/clinic-frx-delivery-log-ui/node_modules/esbuild/lib/main.js:1931:51)
at bundleConfigFile (file:///Users/markbokil/dev/clinic-frx-delivery-log-ui/node_modules/vite/dist/node/chunks/dep-db16f19c.js:63423:26)
The plugin “externalize-deps” was triggered by this import
vite.config.js:3:15:
3 │ import fs from 'fs'
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn’t already an issue that reports the same bug to avoid creating a duplicate.
- Make sure this is a Vite issue and not a framework-specific issue. For example, if it’s a Vue SFC related bug, it should likely be reported to vuejs/core instead.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.
Issue Analytics
- State:
- Created a year ago
- Comments:10 (4 by maintainers)
Top Results From Across the Web
ERROR on compilation Cannot use import statement outside ...
I have made my first own project and i try to build my app and launch it after compilation. When I ...
Read more >Documentation - Module Resolution - TypeScript
Module resolution is the process the compiler uses to figure out what an import refers to. Consider an import statement like import {...
Read more >importlib — The implementation of import — Python 3.11.1 ...
One is to provide the implementation of the import statement (and thus, by extension, the __import__() function) in Python source code.
Read more >3.1. Quickstart — Cabal 3.8.1.0 User's Guide
What does the package build: 1) Executable 2) Library 3) Library and Executable 4) Test suite Your ... Cabal files use “ --...
Read more >Updates - CodeKit
Kit @import statements incorrectly ignored spaces in file paths. ... (There's a bug in the build process that causes crashes on 10.13 and...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
https://stackblitz.com/edit/vitejs-vite-vgmevm?file=package.json&file=vite.config.js
No your analysis of the bug is incorrect. The fs import is needed by our business. Note that I had to include a minimal test case for the reproduction since I can’t add certs to the reproduction. This code below works in 3.1.4 but fails for anything after that. We use certs for HTTPS for Okta security.