Open royporter7 opened 2 months ago
From some more fiddling it looks like this cryptic error message is a result from providing a custom theme object that might not be valid to the createTheme function in next.config.mjs
Actually now that I removed the erroneous theme config that was causing a simple button to not work, I attempted to add a basic Autocomplete straight from the documentation, and I'm getting a very similar error to above. Again, commenting out transformLibraries: ['@mui/material']
causes the error to go away,
<Autocomplete
disablePortal
options={top100Films}
sx={{ width: 300 }}
renderInput={(params) => (
<TextField
{...params}
label="Movie"
/>
)}
/>
The error
TypeError:/node_modules/@mui/material/FilledInput/FilledInput.js: Cannot convert undefined or null to object
at Function.keys (<anonymous>)
at iterateAndReplaceFunctions (/new/node_modules/@pigment-css/react/processors/chunk-RCGCH7H3.js:138:10)
at/node_modules/@pigment-css/react/processors/chunk-RCGCH7H3.js:142:9
at Array.forEach (<anonymous>)
at iterateAndReplaceFunctions (/new/node_modules/@pigment-css/react/processors/chunk-RCGCH7H3.js:138:21)
at/node_modules/@pigment-css/react/processors/chunk-RCGCH7H3.js:142:9
at Array.forEach (<anonymous>)
at iterateAndReplaceFunctions (/new/node_modules/@pigment-css/react/processors/chunk-RCGCH7H3.js:138:21)
at Object.cssFnValueToVariable (/new/node_modules/@pigment-css/react/processors/chunk-RCGCH7H3.js:196:3)
at StyledProcessor.processCss (/new/node_modules/@pigment-css/react/processors/styled.js:385:34)
at StyledProcessor.processStyle (/new/node_modules/@pigment-css/react/processors/styled.js:306:31)
at/node_modules/@pigment-css/react/processors/styled.js:209:12
at Array.forEach (<anonymous>)
at StyledProcessor.build (/new/node_modules/@pigment-css/react/processors/styled.js:208:20)
at/node_modules/@wyw-in-js/transform/lib/plugins/collector.js:26:17
at/node_modules/@wyw-in-js/transform/lib/utils/getTagProcessor.js:384:5
at Array.forEach (<anonymous>)
at applyProcessors (/new/node_modules/@wyw-in-js/transform/lib/utils/getTagProcessor.js:375:10)
at/node_modules/@wyw-in-js/transform/lib/plugins/collector.js:25:42
at EventEmitter.perf (/new/node_modules/@wyw-in-js/transform/lib/utils/EventEmitter.js:45:20)
at collector (/new/node_modules/@wyw-in-js/transform/lib/plugins/collector.js:24:16)
at PluginPass.pre (/new/node_modules/@wyw-in-js/transform/lib/plugins/collector.js:51:26)
at transformFile (/new/node_modules/@babel/core/lib/transformation/index.js:73:27)
at transformFile.next (<anonymous>)
at run (/new/node_modules/@babel/core/lib/transformation/index.js:24:12)
at run.next (<anonymous>)
at/node_modules/@babel/core/lib/transform-ast.js:23:33
at Generator.next (<anonymous>)
at evaluateSync (/new/node_modules/gensync/index.js:251:28)
at sync (/new/node_modules/gensync/index.js:89:14)
at stopHiding - secret - don't use this - v1 (/new/node_modules/@babel/core/lib/errors/rewrite-stack-trace.js:47:12)
at Object.transformFromAstSync (/new/node_modules/@babel/core/lib/transform-ast.js:43:83)
at BaseAction.collect (/new/node_modules/@wyw-in-js/transform/lib/transform/generators/collect.js:50:24)
at collect.next (<anonymous>)
at/node_modules/@wyw-in-js/transform/lib/transform/actions/BaseAction.js:66:78
at EventEmitter.action (/new/node_modules/@wyw-in-js/transform/lib/utils/EventEmitter.js:25:22)
at BaseAction.emitAction (/new/node_modules/@wyw-in-js/transform/lib/transform/actions/BaseAction.js:131:39)
at nextFn (/new/node_modules/@wyw-in-js/transform/lib/transform/actions/BaseAction.js:66:32)
at processNext (/new/node_modules/@wyw-in-js/transform/lib/transform/actions/BaseAction.js:111:28)
at Object.next (/new/node_modules/@wyw-in-js/transform/lib/transform/actions/BaseAction.js:120:9)
at asyncActionRunner (/new/node_modules/@wyw-in-js/transform/lib/transform/actions/actionRunner.js:39:102)
at asyncActionRunner (/new/node_modules/@wyw-in-js/transform/lib/transform/actions/actionRunner.js:46:28)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Object.transform (/new/node_modules/@wyw-in-js/transform/lib/transform.js:107:20)
at async Object.transform (/new/node_modules/@pigment-css/unplugin/build/index.js:273:24)
at async Object.transform (/new/node_modules/unplugin/dist/webpack/loaders/transform.js:108:15)
And the stack trace I posted in the original report proceeds after the above stack trace.
I'm not sure who needs to see this, but I've been continuing on with building my project. The application works fine when running next development server (npm run dev
), however running a build results in the below error, which looks somewhat similar to what I've previously posted above.
Again, commenting out transformLibraries allows me to build the application, however as expected, in the output application the MUI components won't have the custom theme applied.
admin@Admins-MBP new % npm run build
> unnamed-project-new@1.0.0 build
> next build
▲ Next.js 14.2.6
- Environments: .env.local
- Experiments (use with caution):
· instrumentationHook
Creating an optimized production build ...
unhandledRejection Error: EISDIR: illegal operation on a directory, read
at Object.readSync (node:fs:751:3)
at tryReadSync (node:fs:451:20)
at readFileSync (node:fs:497:19)
at get code [as code] (/Users/admin/Repositories/unnamed-project/new/node_modules/@wyw-in-js/transform/lib/transform/Entrypoint.helpers.js:111:99)
at new Entrypoint (/Users/admin/Repositories/unnamed-project/new/node_modules/@wyw-in-js/transform/lib/transform/Entrypoint.js:41:30)
at Entrypoint.innerCreate (/Users/admin/Repositories/unnamed-project/new/node_modules/@wyw-in-js/transform/lib/transform/Entrypoint.js:129:27)
at /Users/admin/Repositories/unnamed-project/new/node_modules/@wyw-in-js/transform/lib/transform/Entrypoint.js:85:47
at EventEmitter.perf (/Users/admin/Repositories/unnamed-project/new/node_modules/@wyw-in-js/transform/lib/utils/EventEmitter.js:45:20)
at Entrypoint.create (/Users/admin/Repositories/unnamed-project/new/node_modules/@wyw-in-js/transform/lib/transform/Entrypoint.js:84:25)
at Entrypoint.createChild (/Users/admin/Repositories/unnamed-project/new/node_modules/@wyw-in-js/transform/lib/transform/Entrypoint.js:176:23)
at BaseAction.processImports (/Users/admin/Repositories/unnamed-project/new/node_modules/@wyw-in-js/transform/lib/transform/generators/processImports.js:22:44)
at processImports.next (<anonymous>)
at /Users/admin/Repositories/unnamed-project/new/node_modules/@wyw-in-js/transform/lib/transform/actions/BaseAction.js:66:78
at EventEmitter.action (/Users/admin/Repositories/unnamed-project/new/node_modules/@wyw-in-js/transform/lib/utils/EventEmitter.js:25:22)
at BaseAction.emitAction (/Users/admin/Repositories/unnamed-project/new/node_modules/@wyw-in-js/transform/lib/transform/actions/BaseAction.js:131:39)
at nextFn (/Users/admin/Repositories/unnamed-project/new/node_modules/@wyw-in-js/transform/lib/transform/actions/BaseAction.js:66:32)
at processNext (/Users/admin/Repositories/unnamed-project/new/node_modules/@wyw-in-js/transform/lib/transform/actions/BaseAction.js:111:28)
at Object.next (/Users/admin/Repositories/unnamed-project/new/node_modules/@wyw-in-js/transform/lib/transform/actions/BaseAction.js:120:9)
at asyncActionRunner (/Users/admin/Repositories/unnamed-project/new/node_modules/@wyw-in-js/transform/lib/transform/actions/actionRunner.js:39:102)
at asyncActionRunner (/Users/admin/Repositories/unnamed-project/new/node_modules/@wyw-in-js/transform/lib/transform/actions/actionRunner.js:46:28)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async asyncActionRunner (/Users/admin/Repositories/unnamed-project/new/node_modules/@wyw-in-js/transform/lib/transform/actions/actionRunner.js:46:22)
at async asyncActionRunner (/Users/admin/Repositories/unnamed-project/new/node_modules/@wyw-in-js/transform/lib/transform/actions/actionRunner.js:46:22)
at async asyncActionRunner (/Users/admin/Repositories/unnamed-project/new/node_modules/@wyw-in-js/transform/lib/transform/actions/actionRunner.js:46:22)
at async asyncActionRunner (/Users/admin/Repositories/unnamed-project/new/node_modules/@wyw-in-js/transform/lib/transform/actions/actionRunner.js:46:22)
at async asyncActionRunner (/Users/admin/Repositories/unnamed-project/new/node_modules/@wyw-in-js/transform/lib/transform/actions/actionRunner.js:46:22)
at async asyncActionRunner (/Users/admin/Repositories/unnamed-project/new/node_modules/@wyw-in-js/transform/lib/transform/actions/actionRunner.js:46:22)
at async asyncActionRunner (/Users/admin/Repositories/unnamed-project/new/node_modules/@wyw-in-js/transform/lib/transform/actions/actionRunner.js:46:22)
at async asyncActionRunner (/Users/admin/Repositories/unnamed-project/new/node_modules/@wyw-in-js/transform/lib/transform/actions/actionRunner.js:46:22)
at async Object.transform (/Users/admin/Repositories/unnamed-project/new/node_modules/@wyw-in-js/transform/lib/transform.js:107:20)
at async Object.transform (/Users/admin/Repositories/unnamed-project/new/node_modules/@pigment-css/unplugin/build/index.js:273:24)
at async Object.transform (/Users/admin/Repositories/unnamed-project/new/node_modules/unplugin/dist/webpack/loaders/transform.js:108:15)
Hmmm, it's looking like some of theses EISDIR error can be circumvented by running the development server with sudo
. After doing so, some build time console errors and warnings showed, resolving them one by one allowed me to run the application as normal. From this I could use Tooltips. However, I'm still getting this issue when I attempt to use an Autocomplete component
Taking a look into this. From the error, it seems like Pigment is trying to read some path as a file but it is a directory. Doing a require.resolve
before reading might help with the fix.
@brijeshb42 Super appreciate you looking into it! If there's something you'd like me to test with my build please let me know and I'll do my best to report back to you.
@rhoiyds Could you push your exact code that's resulting in the error to a github repo ?
@brijeshb42 I've spent the past hour attempting to strip out the sensitive elements of my project into a reproduction, however after stripping everything down, the problem doesn't seem to occur. There's a chance that there's some odd conflict with other logic occurring down the line, and pigment is for reason the one that logs the error. On the main project I'm working on, some things I attempt throw the error -but then starting and stopping the server sometimes fixes the problem. It's very hard to pinpoint the trigger unfortunately.
ADD FORCED CONSOLE LOG WHICH FILES ARE CIRCURED AND IGNORE ARRAY FOR NPM MODULES. So elegant solution
I found out that having any import like import { useTheme } from '@mui/material';
would result in the below pasted error. I replaced all such imports with '@mui/material/styles';
(I am using vite.js.)
error during build:
[commonjs--resolver] /home/bmakan/ws/regressdb3/src/client/node_modules/@mui/material/FilledInput/FilledInput.js: Cannot convert undefined or null to object
file: /home/bmakan/ws/regressdb3/src/client/node_modules/@mui/material/FilledInput/FilledInput.js
TypeError: /home/bmakan/ws/regressdb3/src/client/node_modules/@mui/material/FilledInput/FilledInput.js: Cannot convert undefined or null to object
at Function.keys (<anonymous>)
at iterateAndReplaceFunctions (/home/bmakan/ws/regressdb3/src/client/node_modules/@pigment-css/react/processors/chunk-BSJ525HZ.js:138:10)
at /home/bmakan/ws/regressdb3/src/client/node_modules/@pigment-css/react/processors/chunk-BSJ525HZ.js:142:9
at Array.forEach (<anonymous>)
at iterateAndReplaceFunctions (/home/bmakan/ws/regressdb3/src/client/node_modules/@pigment-css/react/processors/chunk-BSJ525HZ.js:138:21)
at /home/bmakan/ws/regressdb3/src/client/node_modules/@pigment-css/react/processors/chunk-BSJ525HZ.js:142:9
at Array.forEach (<anonymous>)
at iterateAndReplaceFunctions (/home/bmakan/ws/regressdb3/src/client/node_modules/@pigment-css/react/processors/chunk-BSJ525HZ.js:138:21)
at Object.cssFnValueToVariable (/home/bmakan/ws/regressdb3/src/client/node_modules/@pigment-css/react/processors/chunk-BSJ525HZ.js:196:3)
at StyledProcessor.processCss (/home/bmakan/ws/regressdb3/src/client/node_modules/@pigment-css/react/processors/styled.js:385:34)
at StyledProcessor.processStyle (/home/bmakan/ws/regressdb3/src/client/node_modules/@pigment-css/react/processors/styled.js:306:31)
at /home/bmakan/ws/regressdb3/src/client/node_modules/@pigment-css/react/processors/styled.js:209:12
at Array.forEach (<anonymous>)
at StyledProcessor.build (/home/bmakan/ws/regressdb3/src/client/node_modules/@pigment-css/react/processors/styled.js:208:20)
at /home/bmakan/ws/regressdb3/src/client/node_modules/@wyw-in-js/transform/lib/plugins/collector.js:26:17
at /home/bmakan/ws/regressdb3/src/client/node_modules/@wyw-in-js/transform/lib/utils/getTagProcessor.js:384:5
at Array.forEach (<anonymous>)
at applyProcessors (/home/bmakan/ws/regressdb3/src/client/node_modules/@wyw-in-js/transform/lib/utils/getTagProcessor.js:375:10)
at /home/bmakan/ws/regressdb3/src/client/node_modules/@wyw-in-js/transform/lib/plugins/collector.js:25:42
at EventEmitter.perf (/home/bmakan/ws/regressdb3/src/client/node_modules/@wyw-in-js/transform/lib/utils/EventEmitter.js:45:20)
at collector (/home/bmakan/ws/regressdb3/src/client/node_modules/@wyw-in-js/transform/lib/plugins/collector.js:24:16)
at PluginPass.pre (/home/bmakan/ws/regressdb3/src/client/node_modules/@wyw-in-js/transform/lib/plugins/collector.js:51:26)
at transformFile (/home/bmakan/ws/regressdb3/src/client/node_modules/@babel/core/lib/transformation/index.js:73:27)
at transformFile.next (<anonymous>)
at run (/home/bmakan/ws/regressdb3/src/client/node_modules/@babel/core/lib/transformation/index.js:24:12)
at run.next (<anonymous>)
at /home/bmakan/ws/regressdb3/src/client/node_modules/@babel/core/lib/transform-ast.js:23:33
at Generator.next (<anonymous>)
at evaluateSync (/home/bmakan/ws/regressdb3/src/client/node_modules/gensync/index.js:251:28)
at sync (/home/bmakan/ws/regressdb3/src/client/node_modules/gensync/index.js:89:14)
at stopHiding - secret - don't use this - v1 (/home/bmakan/ws/regressdb3/src/client/node_modules/@babel/core/lib/errors/rewrite-stack-trace.js:47:12)
at Object.transformFromAstSync (/home/bmakan/ws/regressdb3/src/client/node_modules/@babel/core/lib/transform-ast.js:43:83)
at BaseAction.collect (/home/bmakan/ws/regressdb3/src/client/node_modules/@wyw-in-js/transform/lib/transform/generators/collect.js:50:24)
at collect.next (<anonymous>)
at /home/bmakan/ws/regressdb3/src/client/node_modules/@wyw-in-js/transform/lib/transform/actions/BaseAction.js:66:78
at EventEmitter.action (/home/bmakan/ws/regressdb3/src/client/node_modules/@wyw-in-js/transform/lib/utils/EventEmitter.js:25:22)
at BaseAction.emitAction (/home/bmakan/ws/regressdb3/src/client/node_modules/@wyw-in-js/transform/lib/transform/actions/BaseAction.js:131:39)
at nextFn (/home/bmakan/ws/regressdb3/src/client/node_modules/@wyw-in-js/transform/lib/transform/actions/BaseAction.js:66:32)
at processNext (/home/bmakan/ws/regressdb3/src/client/node_modules/@wyw-in-js/transform/lib/transform/actions/BaseAction.js:111:28)
at Object.next (/home/bmakan/ws/regressdb3/src/client/node_modules/@wyw-in-js/transform/lib/transform/actions/BaseAction.js:120:9)
at asyncActionRunner (/home/bmakan/ws/regressdb3/src/client/node_modules/@wyw-in-js/transform/lib/transform/actions/actionRunner.js:39:102)
at asyncActionRunner (/home/bmakan/ws/regressdb3/src/client/node_modules/@wyw-in-js/transform/lib/transform/actions/actionRunner.js:46:28)
at async Object.transform (/home/bmakan/ws/regressdb3/src/client/node_modules/@wyw-in-js/transform/lib/transform.js:107:20)
at async Object.transform (/home/bmakan/ws/regressdb3/src/client/node_modules/@pigment-css/vite-plugin/build/index.js:169:24)
at async transform (file:///home/bmakan/ws/regressdb3/src/client/node_modules/rollup/dist/es/shared/node-entry.js:18830:16)
at async ModuleLoader.addModuleSource (file:///home/bmakan/ws/regressdb3/src/client/node_modules/rollup/dist/es/shared/node-entry.js:19046:36)
error: "vite" exited with code 1
Steps to reproduce
Follow the the migration to pigment css example with a basic Next.js project.
Current behavior
Adding in a basic
Seeing that the error is coming from "transform", I comment out the below line in the next.config.mjs file and then the application builds.
transformLibraries: ['@mui/material'],
Expected behavior
The above error doesn't occur when
transformLibraries: ['@mui/material'],
is part of the next.config.mjs file.Context
For now I'll continue on with my project with the transformLibraries commented out, but I don't actually understand how this is going to affect my project. It seems to work with it uncommented.
Your environment
``` System: OS: macOS 13.4.1 Binaries: Node: 20.15.1 - ~/.nvm/versions/node/v20.15.1/bin/node npm: 10.7.0 - ~/.nvm/versions/node/v20.15.1/bin/npm pnpm: Not Found Browsers: Chrome: 127.0.6533.122 Edge: Not Found Safari: 16.5.2 npmPackages: @emotion/react: 11.13.3 @emotion/styled: 11.13.0 @mui/core-downloads-tracker: 6.0.0-rc.0 @mui/material: ^6.0.0-rc.0 => 6.0.0-rc.0 @mui/material-nextjs: ^6.0.0-beta.6 => 6.0.0-dev.240424162023-9968b4889d @mui/material-pigment-css: ^6.0.0-rc.0 => 6.0.0-rc.0 @mui/private-theming: 6.0.0-rc.0 @mui/styled-engine: 6.0.0-rc.0 @mui/system: 6.0.0-rc.0 @mui/types: 7.2.15 @mui/utils: 6.0.0-rc.0 @types/react: latest => 18.3.4 react: latest => 18.3.1 react-dom: latest => 18.3.1 typescript: latest => 5.5.4 ```npx @mui/envinfo
Search keywords: pigment transformLibraries EISDIR
Search keywords: