vercel / next.js

The React Framework
https://nextjs.org
MIT License
126.4k stars 26.9k forks source link

Error [BABEL]: ... "Cannot find module 'js-levenshtein'" #12820

Closed lauralouiset closed 4 years ago

lauralouiset commented 4 years ago

Bug report

I've tried with my custom babel.config.js file, I've tried having deleted said file (which isn't doing much) but I'm getting a compilation error after upgrading from 9.3.6 to 9.4.0.

Possibly related to #12779 and/or #12740

Describe the bug

A clear and concise description of what the bug is.

Compilation bug in the console of VSCode:

error - ./node_modules/next/dist/client/dev/amp-dev.js Error: [BABEL] /**myfilepaths**/node_modules/next/dist/client/dev/amp-dev.js: Cannot find module 'js-levenshtein' Require stack:

here's my next.config:

module.exports = {
  publicRuntimeConfig: config,
  serverRuntimeConfig: config,
  webpack(config, options = {}) { 
    config.module.rules.push({
      test: /\.svg$/,
      use: [
        {
          loader: 'react-svg-loader',
        },
      ],
    },
    {
      test: /\.(png|jpe?g|gif)$/i,
      use: [
        {
          loader: 'file-loader',
        },
      ],
    })
    return config;
  },
}

To Reproduce

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

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior

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

Screenshots

If applicable, add screenshots to help explain your problem.

System information

Additional context

Add any other context about the problem here.

lauralouiset commented 4 years ago

Hmm. it appears that @babel/preset-env swapped their levenshtein distance package from js-levenshtein to levenary in 7.8.0 babel/babel@30f3b07#diff-cf817afef443d0d96acf65275e0edf13.

lauralouiset commented 4 years ago

yarn cache clean didn't fix it -- however, deleting /node_nodules and .next folder and doing fresh yarn install seems to fix the issue. Closing -- hope this can help anyone else who comes across this error message.

thomaszdxsn commented 4 years ago

same error when upgrade next.js version, resolved by delete node_modules.

but in vercel, deploy is fail, since it used build cache

kennand commented 4 years ago

+1 for amplify. Needing to rm -rf node_modules before yarn install on builds.

morganfeeney commented 3 years ago

@thomaszdxsn I ran into this issue just now, simply using vercel cli to deploy resolved it for the deployment part. I went through the steps listed here, e.g. remove node_modules but as I have a github action that kicks off a deployment on vercel after a push, the Error [BABEL]: ... "Cannot find module 'js-levenshtein' error persisted until I used vercel cli.

balazsorban44 commented 2 years ago

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.