Module not found: Can't resolve 'encoding' './node_modules/node-fetch/lib/index.js'
See original GitHub issueBug 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:
- git clone https://github.com/zeit/next-learn-demo.git
- cd next-learn-demo
- cd 7-styling-components
- npm install
- “scripts”: { “build”: “next build”, “now-build”: “next build”, “start”: “next start” },
- touch next.config.js module.exports = { target: ‘serverless’ };
- touch next.json { “version”: 2, “builds”: [{ “src”: “package.json”, “use”: “@now/next” }] }
- 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:
- Created 4 years ago
- Reactions:2
- Comments:13 (4 by maintainers)

Top Related StackOverflow Question
`./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 !
Deleting .next folder fixes similar problems.