Error: Cannot find module 'ejs'

后端 未结 29 2033
南方客
南方客 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 05:53

    I ran into this problem after I forgot to install ejs before the first time I ran my app. For some reason ejs was not being seen after installing it later. I found a quick, clean, and effective solution to this problem which was to reinstall express by running npm uninstall express then npm install express in the local directory before restarting the server.

    0 讨论(0)
  • 2020-12-13 05:54

    I had this problem. I debugged using node-inspector and saw that from the node_modules folder where the express source files were, ejs was not installed. So I installed it there and it worked.

    npm install -g ejs didn't put it where I expected it to despite NODE_PATH being set to the same node_modules folder. Prob doing it wrong, just started with node.

    0 讨论(0)
  • 2020-12-13 05:54

    I think ejs template engine is not properly installed on your machine. You just install the template engine using npm

    npm install ejs --save
    

    then include the following code in app.js

    app.set('view engine', 'ejs')
    
    0 讨论(0)
  • 2020-12-13 05:55

    In my case, I just uninstall then install ejs again.

    npm uninstall ejs
    

    then

    npm install ejs
    
    0 讨论(0)
  • 2020-12-13 05:55

    The error hit me when i was working on goormIDE. This happens basically when node packages arent inside the running file. The place where app.js or home.js is executed.

    0 讨论(0)
  • 2020-12-13 05:56

    I my case, I just added ejs manually in package.json:

     {
       "name": "myApp"
       "dependencies": {
         "express": "^4.12.2",
         "ejs": "^1.0.0"
       }
     }
    

    And run npm install (may be you need run it with sudo) Please note, that ejs looks views directory by default

    0 讨论(0)
提交回复
热议问题