Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
438 views
in Technique[技术] by (71.8m points)

reactjs - npm run dev ERR - cannot find module and cannot solve with 'npm install'

I have created a next.js app, but when I try to npm run dev, it shows this error to me.

npm run dev error

What should I do?

  • Node.js version: 12.0.0

  • npm version: 7.10.2

I also have tried npm install and then npm run dev but it still got the same problem.

My script from package.json

{
  "name": "with-mongodb",
  "version": "0.1.0",
  "scripts": {
    "dev": "next dev",
    "build": "next build",
    "start": "next start"
  },
  "dependencies": {
    "mongodb": "^3.5.9",
    "next": "latest",
    "react": "^16.13.1",
    "react-dom": "^16.13.1"
  },
  "license": "MIT"
}

Edit: I created the project by running the following command:

npx create-next-app --example with-mongodb mflix

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I think I found the cause of this issue. I believe you are using windows

I am expecting every time you quit or exit the dev environment. Terminal asks you to confirm Terminate batch job (Y/N). In case you press Y PowerShell removes some files from next's package. And then next time you are not able to run the dev environment.

Everything will work fine if you press N and you do not Terminate batch job.

unfortunately, I don't know how PowerShell works on Windows and why it's asking you to Terminate batch job.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...