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.

Module not found: Can't resolve 'encoding' './node_modules/node-fetch/lib/index.js'

See original GitHub issue

Bug report

After downloading the Tutorial from git clone https://github.com/zeit/next-learn-demo.git cd next-learn-demo cd 7-styling-components

then following ZEIT Now deployment procedures as outlined in the tutorial: https://nextjs.org/learn/basics/deploying-a-nextjs-app/run-two-instances

Describe the bug

Unable to run npm run build across multiple projects and enviornments. Build compiles with warnings when isomorphic-unfetch is called. Unable to deploy ZEIT Now.

A clear and concise description of what the bug is.

To Reproduce

NPM v: 6.9.0 NODE v: 12.4.0 NEXT.js v: 8.1.0 Mac OS VS Code Terminal

Steps to reproduce the behavior, please provide code snippets or a repository:

  1. git clone https://github.com/zeit/next-learn-demo.git
  2. cd next-learn-demo
  3. cd 7-styling-components
  4. npm install
  5. “scripts”: { “build”: “next build”, “now-build”: “next build”, “start”: “next start” },
  6. touch next.config.js module.exports = { target: ‘serverless’ };
  7. touch next.json { “version”: 2, “builds”: [{ “src”: “package.json”, “use”: “@now/next” }] }
  8. npm run build ERROR `Compiled with warnings.

./node_modules/node-fetch/lib/index.js Module not found: Can’t resolve ‘encoding’ in ‘/Users/Documents/next-learn-demo/7-styling-components/node_modules/node-fetch/lib’

┌ / ├ /_app ├ /_document ├ /_error ├ /about └ /post`

Expected behavior

compiling successfully. Only happens when API key is involved Began happening last night, have been attempting work arounds all day with no resolve

A clear and concise description of what you expected to happen.

Screenshots

If applicable, add screenshots to help explain your problem.

System information

  • OS: [e.g. macOS, Windows]
  • Browser (if applies) [e.g. chrome, safari]
  • Version of Next.js: [e.g. 6.0.2]

Additional context

Add any other context about the problem here.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:13 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
AbuHanicommented, Sep 1, 2020

`./node_modules/next/dist/next-server/server/load-components.js Critical dependency: the request of a dependency is an expression

./node_modules/next/dist/next-server/server/load-components.js Critical dependency: the request of a dependency is an expression

./node_modules/next/dist/next-server/server/require.js Critical dependency: the request of a dependency is an expression

./node_modules/next/dist/next-server/server/require.js Critical dependency: the request of a dependency is an expression

./node_modules/next/dist/next-server/server/require.js Critical dependency: the request of a dependency is an expression

./node_modules/node-fetch/lib/index.js Module not found: Can’t resolve ‘encoding’`

i got these warnings on production build !

3reactions
talaikiscommented, Aug 31, 2020

Deleting .next folder fixes similar problems.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error: Can't resolve 'encoding' when deploying Next.js ...
Module not found : Error: Can't resolve 'encoding' when deploying Next.js Commerce template · Run yarn add encoding in your project directory ...
Read more >
npm cannot find module 'encoding' - Stack Overflow
I tried to install other node packages but didn't work, same error. rm -rf node_modules && npm install I tried the command in...
Read more >
Error: Could not find “encoding” module in file, Netlify function
My build is currently failing to build a function which only uses the 'node-fetch' lib [0]. The build runs successfully using the local...
Read more >
yeah :( i'm not quite sure why... - Replit
node_modules /node-fetch/lib/index.mjs 1264:16-19 ... node_modules/@replit/database/index.js ... Module not found: Error: Can't resolve 'encoding' in '.
Read more >
cannot find module [Node npm Error Solved] - freeCodeCamp
If you're a developer that works with Node JS and JavaScript ... in the format "Module not found: Error: Can't resolve 'package name'...
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