Error: Cannot find module html

前端 未结 5 650
情书的邮戳
情书的邮戳 2020-12-04 19:28

I have not used Node.js for a long time and never used express. When I started my application, it just returned :

Error: Cannot find module \'html\'
  at Fun         


        
5条回答
  •  旧巷少年郎
    2020-12-04 19:58

    This is what i did for rendering html files. And it solved the errors. Install consolidate and mustache by executing the below command in your project folder.

    $ sudo npm install consolidate mustache --save
    

    And make the following changes to your app.js file

    var engine = require('consolidate');
    
    app.set('views', __dirname + '/views');
    app.engine('html', engine.mustache);
    app.set('view engine', 'html');
    

    And now html pages will be rendered properly.

提交回复
热议问题