question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Next JS dev mode: ReferenceError: File is not defined

See original GitHub issue

Bug 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

  1. Create a Next JS app
  2. Install Material UI
  3. Install Material UI Dropzone
  4. Create a simple DropzoneArea on a page
  5. Start the application in dev mode: npm run dev
  6. 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:

error

Versions

  • OS: Ubuntu 18.04
  • Browser: chrome
  • @material-ui/core version: ^4.9.11
  • material-ui-dropzone version: ^3.3.0

Additional context

Console error log: localhost-1593081881279.log

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:9 (1 by maintainers)

github_iconTop GitHub Comments

4reactions
Nigorrocommented, Jun 25, 2020

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

1reaction
cayassocommented, Jul 21, 2020

Can you please publish version 3.3.1 to NPM? the latest version is still showing 3.3.0

Read more comments on GitHub >

github_iconTop Results From Across the Web

File is not defined when using useFieldArray · Issue #3570 ...
In a Next.js project, in an SSR-ed page, I'm not able to use useFieldArray . ... Steps to reproduce the behavior: Use a...
Read more >
Fixing Next js "ReferenceError: document is not defined"
In this tutorial I'll show you three ways on how to solve this issue. Solution 2:
Read more >
Next.js: document is not defined
I think, in server rendering mode, the document is undefined. You should be able to use it inside class lifecycle methods or useEffect...
Read more >
module-not-found
The module you're trying to import is in a different directory. Make sure that the path you're importing refers to the right directory...
Read more >
How to Fix "window is not defined" in Next.js
This issue has to do with Server-Side Rendering in Next.js. Next.js will by default try to use SSR for your site. This means...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found