Error: Cannot find module 'ejs'

后端 未结 29 2082
南方客
南方客 2020-12-13 05:33

Here is my complete error:

Error: Cannot find module \'ejs\'
    at Function._resolveFilename (module.js:317:11)
    at Function._load (module.js:262:25)
            


        
29条回答
  •  青春惊慌失措
    2020-12-13 06:07

    npm install ejs --save worked for me ! ✅

    On goormIDE, I had this file configuration :

    • container
      • main.js
      • package-lock.json
      • package.json
      • node_modules
      • views
        • home.ejs

    In my main.js file, I also had this route

    app.get("/", function(req, res){
    res.render("home.ejs");
    })
    

    npm install ejs -g didn't add the corresponding dependency within the package.json. npm install ejs --save did. I executed the command line from the container directory. Manually it could have been added into the package.json with : **

    "dependencies": {
        "ejs": "^3.0.2",}
    

    **

提交回复
热议问题