Error: Cannot find module 'ejs'

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

    Install express locally

    (npm install express while in the project's root directory)


    Your project depends on both express and ejs, so you should list them both as dependencies in your package.json.

    That way when you run npm install in you project directory, it'll install both express and ejs, so that var express = require('express') will be the local installation of express (which knows about the ejs module that you installed locally) rather than the global one, which doesn't.

    In general it's a good idea to explicitly list all dependencies in your package.json even though some of them might already be globally installed, so you don't have these types of issues.

提交回复
热议问题