简体   繁体   中英

Next.js: ./node_modules/next/dist/client/dev/amp-dev.js

I have a very serious issue right now trying to use Next js. No matter what version I use, any time I try to run the npm run dev , I get the following error:

error - ./node_modules/next/dist/client/dev/amp-dev.js
Module not found: Can't resolve 'C:\Usersudbasili\Documents\Programming\Acumen Developers\myportfolio\node_modules\next\dist\compiled\regenerator-runtime\runtime.js' in 'C:\Users\udbasili\Documents\Programming\Acumen Developers\myportfolio\node_modules\next\dist\client\dev'      
error - Error: Cannot find module 'C:\Users\udbasili\Documents\Programming\Acumen Developers\myportfolio\.next\fallback-build-manifest.json'Require stack:

This is literally right after running the create next app command, so I don't install any additional package. One thing realized though is that this error doesn't occur when I use the public folder on my window PC but when I use the user folder called udbasili I get the above error. I have been using next.js for a long time and this is the first I am seeing this error

If you compare the paths, there is a missing '\' :

'C:\Users**\**udbasili\Documents\Programming\Acumen Developers...' 'C:\Usersudbasili\Documents\Programming\Acumen Developers...'

A quick solution that I gave to this issue was create the project in different path. For example:

'C:\dev\myportfolio'

It's possible your autoimport included '/dist/client/dev' in the 'next/amp' path.

Does it work if you import { useAmp } from 'next/amp' ?

I had the same issue the problem was that my project files was in a folder beginning with "ud". My folder name was "udemy". Renaming that folder or moving the project outside that folder solved the issue

Please head over to https://nextjs.org/docs/messages/swc-disabled

By disabling swc in next.config.js it will resolve your issue.

You can disable swc by adding:

  experimental: {
    forceSwcTransforms: true,
  }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM