简体   繁体   中英

Azure Node.JS Tutorial Default Template Engine

Im following the tutorial here . I when trying to run the project at this point. I get an error saying that there is no defined templating engine. The tutorial has us remove the app.use

Below is my console error when trying to go through the tutorial. Just to be sure I went back through it three times. I get the same error. I notice in the History.md that this was addressed but I cant figure out what if anything i am supposed to do with that info. Can you advise?

This is the tutorial: https://azure.microsoft.com/en-us/documentation/articles/documentdb-nodejs-application/

I get the error on trying to run npm start to see the todo UI. When I run start at the beginning of the tutorial, it works.

Thank you.


Kaona (master *) todo $ npm start
> todo@0.0.0 start /Users/Kaona/GitHub/todo

> node ./bin/www



/Users/Kaona/GitHub/todo/node_modules/express/lib/view.js:62

    throw new Error('No default engine was specified and no extension was provided.');

    ^



Error: No default engine was specified and no extension was provided.

    at new View (/Users/Kaona/GitHub/todo/node_modules/express/lib/view.js:62:11)

    at EventEmitter.render (/Users/Kaona/GitHub/todo/node_modules/express/lib/application.js:569:12)

    at ServerResponse.render (/Users/Kaona/GitHub/todo/node_modules/express/lib/response.js:961:7)

    at /Users/Kaona/GitHub/todo/routes/tasklist.js:27:17

    at /Users/Kaona/GitHub/todo/models/taskDao.js:43:17

    at Base.defineClass._toArrayImplementation (/Users/Kaona/GitHub/todo/node_modules/documentdb/lib/queryIterator.js:187:17)

    at /Users/Kaona/GitHub/todo/node_modules/documentdb/lib/queryIterator.js:183:26

    at /Users/Kaona/GitHub/todo/node_modules/documentdb/lib/queryIterator.js:234:17

    at successCallback (/Users/Kaona/GitHub/todo/node_modules/documentdb/lib/documentclient.js:2069:17)

    at IncomingMessage.<anonymous> (/Users/Kaona/GitHub/todo/node_modules/documentdb/lib/request.js:84:13)

Per @ryancrawcour @larrymaccherone's direction. The solution is to add app.set('view engine', 'jade'); to the app.js file in the tutorial. See Error: No default engine was specified and no extension was provided

According to the error, I guess your machine is a Mac, but I think my steps below on linux that's similar with yours on MacOS.

The tutorial sample shows a local node app created by express generator for using Azure DocumentDB.

So the first step is creating an Azure DocumentDB instance on Azure new portal. I think it's simple, and copy the connection information of the DocumentDB created for the express app.

To create a express app like the tutorial doing, I did the steps below.

  1. Command npm install express-generator -g

    On MacOS, may need to add the prefix cmd sudo because it's for global env, see http://expressjs.com/en/starter/generator.html ).

  2. Command express todo

    Generate a empty express app via express generator

  3. Command cd todo && npm install

    installation for dependent libraries registed in the package.json

  4. Now, you can command npm start in the dir todo and browse the url http://localhost:3000
  5. Command git clone https://github.com/Azure-Samples/documentdb-node-todo-app.git from Github project https://github.com/Azure-Samples/documentdb-node-todo-app and copy the files of the path src of git repo to the dir todo .
  6. Edit & configure the config.js with the connection information of your DocumentDB.

Hope it helps. Best Regards.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM