[go: nahoru, domu]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
brookton opened this issue Jun 20, 2019 · 13 comments

Comments

@brookton
Copy link
Contributor

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.

@lfades
Copy link
Member
lfades commented Jun 22, 2019

@brookton The build is showing a warning about encoding, it's an optional package and you don't need to have it installed, you can safely ignore that warning, the build and deployment should be okay (I have tested both: https://7-styling-components.fades.now.sh/), if the build/start scripts don't work please update to next@canary.

You may need custom routes to handle the /p/:id paths that are handled by the custom server, I'll get rid of that custom server from the example very soon, because you can either use Now routes or the new dynamic routes of Next.js that will be out soon.

@lfades lfades closed this as completed Jun 22, 2019
@samuelcastro

This comment has been minimized.

@timneutkens
Copy link
Member

@samuelcastro doing that means you're bundling server-only dependencies and shipping them to the browser, so in general I wouldn't recommend adding that config.

@samuelcastro
Copy link
samuelcastro commented Nov 28, 2019

Ok @timneutkens , so how do you suggest to fix it then? I can't deploy with now without ignoring it.

@timneutkens
Copy link
Member

@samuelcastro does the deployment error? Because it shouldn't be.

@samuelcastro
Copy link
samuelcastro commented Nov 28, 2019

@timneutkens Yes, deployment in failing on now with this issue.

@samuelcastro
Copy link

nvm, seems to be ok now, it was not deploying with this error but it might be something else.

@Toyurc
Copy link
Toyurc commented Mar 23, 2020

Hi, this exact error is happening on my production app, any fixes for it, I am running next@9.0.0

@talaikis
Copy link

Deleting .next folder fixes similar problems.

@AbuHani
Copy link
AbuHani commented 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 !

@priley86
Copy link
priley86 commented Mar 28, 2021

yarn add -D encoding seems to resolve the encoding reference, but still seeing the other warnings above here. More reading:
#10633

@Milutin-P
Copy link
Milutin-P commented Mar 31, 2021

What solved it for me was doing both things users above me proposed.

  1. Deleting .next folder
  2. yarn add -D encoding

Hope that will be the case for you too 🤞🏼

@balazsorban44
Copy link
Member

This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@vercel vercel locked as resolved and limited conversation to collaborators Jan 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants