Error: Cannot find module 'ejs'

后端 未结 29 2034
南方客
南方客 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:15

    Add dependency in package.json and then run npm install

        {
      ...
      ... 
      "dependencies": {
        "express": "*",
        "ejs": "*",
      }
    }
    
    0 讨论(0)
  • 2020-12-13 06:16

    In my case there was no silly syntax error, but same error arised. I had installed ejs and ejs-mate globally. I installed it locally and found my error resolved.

    0 讨论(0)
  • 2020-12-13 06:16

    Installing express locally solved my same problem. npm i express --save

    0 讨论(0)
  • 2020-12-13 06:18

    I had the same issue. Once I set environment variable NODE_PATH to the location of my modules (/usr/local/node-v0.8.4/node_modules in my case) the problem went away. P.S. NODE_PATH accepts a colon separated list of directories if you need to specify more than one.

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

    and then in the terminal

    npm install ejs --save 
    

    resolves the issue

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