Next JS dev mode: ReferenceError: File is not defined
See original GitHub issueBug Report
Describe the bug
When attempting to use DropzoneArea in a Next JS app (running with npm run dev
) which is using Material UI, the attached error occurs in console, and the following error is displayed in the window:
ReferenceError: File is not defined (anonymous function) /home/tristan/Documents/git_repos/GitHub/Optimaized/MisTecnicos/mistecnicos-web-app/node_modules/material-ui-dropzone/dist/index.js:1166:77 Module._compile internal/modules/cjs/loader.js:1123:30 Module._extensions…js internal/modules/cjs/loader.js:1143:10 Module.load internal/modules/cjs/loader.js:972:32 Function.Module._load internal/modules/cjs/loader.js:872:14 Module.require internal/modules/cjs/loader.js:1012:19 require internal/modules/cjs/helpers.js:72:18 material-ui-dropzone webpack:/external “material-ui-dropzone”:1 1 | module.exports = require(“material-ui-dropzone”); View compiled webpack_require ./webpack/bootstrap:21 18 | // Execute the module function 19 | var threw = true; 20 | try { 21 | modules[moduleId].call(module.exports, module, module.exports, webpack_require); | ^ 22 | threw = false; 23 | } finally { 24 | if(threw) delete installedModules[moduleId]; View compiled Module…/pages/test/index.js /_next/development/server/static/development/pages/test.js:110:78 webpack_require ./webpack/bootstrap:21 18 | // Execute the module function 19 | var threw = true; 20 | try { 21 | modules[moduleId].call(module.exports, module, module.exports, webpack_require); | ^ 22 | threw = false; 23 | } finally { 24 | if(threw) delete installedModules[moduleId]; View compiled 3 /_next/development/server/static/development/pages/test.js:195:18 webpack_require ./webpack/bootstrap:21 18 | // Execute the module function 19 | var threw = true; 20 | try { 21 | modules[moduleId].call(module.exports, module, module.exports, webpack_require); | ^ 22 | threw = false; 23 | } finally { 24 | if(threw) delete installedModules[moduleId]; View compiled ▼ 3 stack frames were expanded. (anonymous function) /home/tristan/Documents/git_repos/GitHub/Optimaized/MisTecnicos/mistecnicos-web-app/.next/server/static/development/pages/test.js:91:18 (anonymous function) /_next/development/server/static/development/pages/test.js:94:10 Module._compile internal/modules/cjs/loader.js:1123:30
Steps to reproduce
- Create a Next JS app
- Install Material UI
- Install Material UI Dropzone
- Create a simple DropzoneArea on a page
- Start the application in dev mode:
npm run dev
- Load the page
Expected behavior
Run the page without errors on both dev and production mode. It works with npm run build && npm start
, but not with npm run dev
### Screenshots
See the screenshot below:
Versions
- OS: Ubuntu 18.04
- Browser: chrome
@material-ui/core
version: ^4.9.11material-ui-dropzone
version: ^3.3.0
Additional context
Console error log: localhost-1593081881279.log
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:9 (1 by maintainers)
I got the same error with Nextjs and Material-ui. Perhaps this is a bug in the new version of
material-ui-dropzone
.I installed the previous version and it helped me.
Try:
npm i material-ui-dropzone@3.2.1 -s
Can you please publish version 3.3.1 to NPM? the latest version is still showing 3.3.0