Node.js Error: Cannot find module express

前端 未结 15 1557
情话喂你
情话喂你 2020-12-22 18:56

I wrote my first node.js app, but it can\'t find express library:

C:\\ChatServer\\Server>node server.js

module.js:340
    throw err;
          ^
Error: C         


        
15条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-22 19:03

    I had the same error following the example on this book: "Kubernetes Up & Running".
    I see many answers suggesting to install express "by hand" but I'm not convinced is the best solution.
    Because we are using package.json (I can see it in the logs) and the right way to build the app is running npm install, I added the express dependency in the package.json file.

     "dependencies": {
        "express": "^4.17.1"
    }
    

    I get the current version with npm search express.

提交回复
热议问题