vite-plugin-node-polyfills
vite-plugin-node-polyfills copied to clipboard
Bug: ENOTDIR: not a directory, open '/xxx/node_modules/.pnpm/[email protected]/node_modules/node-stdlib-browser/esm/mock/empty.js/promises'
Summary
log:
> tsc -b && vite build
Production Mode: true
♻️ Generating routes...
✅ Processed routes in 122ms
vite v6.1.1 building for production...
✓ 1820 modules transformed.
x Build failed in 9.99s
error during build:
[vite:load-fallback] Could not load /opt/developer/go_code/qdi/ui/node_modules/.pnpm/[email protected]/node_modules/node-stdlib-browser/esm/mock/empty.js/promises (imported by node_modules/.pnpm/@[email protected]_@[email protected][email protected][email protected][email protected]_/node_modules/@tanstack/router-generator/dist/esm/generator.js): ENOTDIR: not a directory, open '/opt/developer/go_code/qdi/ui/node_modules/.pnpm/[email protected]/node_modules/node-stdlib-browser/esm/mock/empty.js/promises'
at async open (node:internal/fs/promises:638:25)
at async Object.readFile (node:internal/fs/promises:1242:14)
at async Object.load (file:///opt/developer/go_code/qdi/ui/node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected][email protected][email protected]/node_modules/vite/dist/node/chunks/dep-Cg8OuIew.js:51859:25)
at async PluginDriver.hookFirstAndGetPlugin (file:///opt/developer/go_code/qdi/ui/node_modules/.pnpm/[email protected]/node_modules/rollup/dist/es/shared/node-entry.js:21735:28)
at async file:///opt/developer/go_code/qdi/ui/node_modules/.pnpm/[email protected]/node_modules/rollup/dist/es/shared/node-entry.js:20858:33
at async Queue.work (file:///opt/developer/go_code/qdi/ui/node_modules/.pnpm/[email protected]/node_modules/rollup/dist/es/shared/node-entry.js:21945:32)
ELIFECYCLE Command failed with exit code 1.
package.json
{
"name": "ui",
"private": true,
"version": "0.0.0",
"type": "module",
"packageManager": "[email protected]",
"pnpm": {
"onlyBuiltDependencies": [
"@swc/core",
"esbuild"
]
},
"scripts": {
"dev": "vite",
"build": "tsc -b && vite build",
"lint": "eslint .",
"preview": "vite preview"
},
"dependencies": {
"@bprogress/core": "^1.1.15",
"@hookform/resolvers": "^4.1.0",
"@radix-ui/react-avatar": "^1.1.3",
"@radix-ui/react-collapsible": "^1.1.3",
"@radix-ui/react-dialog": "^1.1.6",
"@radix-ui/react-dropdown-menu": "^2.1.6",
"@radix-ui/react-label": "^2.1.2",
"@radix-ui/react-menubar": "^1.1.6",
"@radix-ui/react-navigation-menu": "^1.2.5",
"@radix-ui/react-popover": "^1.1.6",
"@radix-ui/react-select": "^2.1.6",
"@radix-ui/react-separator": "^1.1.2",
"@radix-ui/react-slider": "^1.2.3",
"@radix-ui/react-slot": "^1.1.2",
"@radix-ui/react-tooltip": "^1.1.8",
"@tanstack/react-router": "^1.109.2",
"class-variance-authority": "^0.7.1",
"clsx": "^2.1.1",
"i18next": "^24.2.2",
"i18next-browser-languagedetector": "^8.0.4",
"i18next-chained-backend": "^4.6.2",
"i18next-localstorage-backend": "^4.2.0",
"lucide-react": "^0.475.0",
"next-themes": "^0.4.4",
"openai": "^4.85.3",
"react": "^19.0.0",
"react-dom": "^19.0.0",
"react-hook-form": "^7.54.2",
"react-i18next": "^15.4.1",
"sonner": "^2.0.1",
"tailwind-merge": "^3.0.1",
"tailwindcss-animate": "^1.0.7",
"zod": "^3.24.2"
},
"devDependencies": {
"@eslint/js": "^9.20.0",
"@iconify/json": "^2.2.309",
"@iconify/tailwind4": "^1.0.3",
"@swc/core": "^1.10.18",
"@tailwindcss/postcss": "^4.0.7",
"@tailwindcss/vite": "^4.0.7",
"@tanstack/eslint-plugin-router": "^1.105.0",
"@tanstack/router-devtools": "^1.109.2",
"@tanstack/router-generator": "^1.109.2",
"@tanstack/router-plugin": "^1.109.2",
"@types/node": "^22.13.4",
"@types/react": "^19.0.10",
"@types/react-dom": "^19.0.4",
"@vitejs/plugin-react": "^4.3.4",
"@vitejs/plugin-react-swc": "^3.8.0",
"autoprefixer": "^10.4.20",
"babel-plugin-react-compiler": "19.0.0-beta-30d8a17-20250209",
"eslint": "^9.20.1",
"eslint-plugin-react-hooks": "^5.1.0",
"eslint-plugin-react-refresh": "^0.4.19",
"globals": "^15.15.0",
"node-stdlib-browser": "^1.3.1",
"postcss": "^8.5.3",
"react-compiler-runtime": "19.0.0-beta-30d8a17-20250209",
"tailwindcss": "^4.0.7",
"typescript": "^5.7.3",
"typescript-eslint": "^8.24.1",
"vite": "^6.1.1",
"vite-plugin-node-polyfills": "^0.23.0"
}
}
same issue
Similar issue without promise.
The same version, anybody want to solve this?
vite v6.1.0 building for production...
│ ✓ 64 modules transformed.
│ x Build failed in 1.74s
│ error during build:
│ src/Popup.tsx (6:9): "existsSync" is not exported by "../../node_modules/.pnpm/[email protected]/node_modules/node-stdlib-browser/esm/mock/empty.js"
│ , imported by "src/Popup.tsx".
│ file: D:/Projekty/chrome-extension-boilerplate-react-vite/pages/popup/src/Popup.tsx:6:9
│
│ 4: import { exampleThemeStorage } from '@extension/storage';
│ 5: import { ToggleButton } from '@extension/ui';
│ 6: import { existsSync } from 'node:fs';
│ ^
│ 7: import { resolve } from 'node:path';
│
│ at getRollupError (file:///D:/Projekty/chrome-extension-boilerplate-react-vite/node_modules/.pnpm/[email protected]/node_modules/rollup/dist/es/shared/parse
│ Ast.js:397:41)
│ at error (file:///D:/Projekty/chrome-extension-boilerplate-react-vite/node_modules/.pnpm/[email protected]/node_modules/rollup/dist/es/shared/parseAst.js:39
│ 3:42)
│ at Module.error (file:///D:/Projekty/chrome-extension-boilerplate-react-vite/node_modules/.pnpm/[email protected]/node_modules/rollup/dist/es/shared/node-en
│ try.js:16603:16)
│ at Module.traceVariable (file:///D:/Projekty/chrome-extension-boilerplate-react-vite/node_modules/.pnpm/[email protected]/node_modules/rollup/dist/es/shared
│ /node-entry.js:17052:29)
│ at ModuleScope.findVariable (file:///D:/Projekty/chrome-extension-boilerplate-react-vite/node_modules/.pnpm/[email protected]/node_modules/rollup/dist/es/sh
│ ared/node-entry.js:14709:39)
│ at ReturnValueScope.findVariable (file:///D:/Projekty/chrome-extension-boilerplate-react-vite/node_modules/.pnpm/[email protected]/node_modules/rollup/dist/
│ es/shared/node-entry.js:5582:38)
│ at FunctionBodyScope.findVariable (file:///D:/Projekty/chrome-extension-boilerplate-react-vite/node_modules/.pnpm/[email protected]/node_modules/rollup/dist
│ /es/shared/node-entry.js:5582:38)
│ at Identifier.bind (file:///D:/Projekty/chrome-extension-boilerplate-react-vite/node_modules/.pnpm/[email protected]/node_modules/rollup/dist/es/shared/node
│ -entry.js:5356:40)
│ at CallExpression.bind (file:///D:/Projekty/chrome-extension-boilerplate-react-vite/node_modules/.pnpm/[email protected]/node_modules/rollup/dist/es/shared/
│ node-entry.js:2783:23)
│ at CallExpression.bind (file:///D:/Projekty/chrome-extension-boilerplate-react-vite/node_modules/.pnpm/[email protected]/node_modules/rollup/dist/es/shared/
│ node-entry.js:11865:15)
│ ELIFECYCLE Command failed with exit code 1.
│
│ command finished with error: command (D:\Projekty\chrome-extension-boilerplate-react-vite\pages\popup) C:\Users\pkuni\AppData\Local\pnpm\pnpm.exe run build
│ exited (1)
└────>
× Internal errors encountered: unable to determine why task exited,unable to determine why task exited,unable to determine why task exited,unable to determine why task exited,unable to
│ determine why task exited
ELIFECYCLE Command failed with exit code 1.
ELIFECYCLE Command failed with exit code 1.
For:
plugins: [
nodePolyfills({
include: ['fs', 'path'],
protocolImports: true,
}),
],
When i've tried to import:
import fs from 'node:fs';
Then:
I have same issue with
"vite-plugin-node-polyfills": "^0.9.0",
p/s: works fine with
"vite-plugin-node-polyfills": "^0.23.0",
@davidmyersdev Are you able to fix it, because i really want it 🥺
same issue
Any moves forward?
Same issue: this library says it mocks / supports protocolImports, but it doesn't. node:fs/promises is not supported.
if you look in the node_modules folder, you see that the empty.js file has no module defined in it called promises, which (i think) is the only way that the import ...empty.js/promises would be valid in the first place. @davidmyersdev is this easily resolvable? or should i refactor this code out of my app?
Problem here is related to this dep: https://github.com/niksy/node-stdlib-browser/issues/3
I experience the same issue. Looks like a complex one to solve