Express and Express Generator

0

I understood that the express generator only creates boilerplate pro project. But I do not quite understand what the correct way to add it to the project is

I need to install the 2, or just the generator would already suffice?

  • I create the project folder and give npm init
  • npm i express --save
  • npm i express-generator --save
  • expressApp_name
  • Not sure, because I now have 2 package.json. Is there a problem with node_modules being outside the project folder (test-gen)?

    The file structure looks like this:

        
    asked by anonymous 05.08.2018 / 06:43

    1 answer

    2

    First you do not need to create the folder and you do not need to give npm init, just follow what the documentation talks about.

    Install global generator npm i express-generator -g

    Check available options express -h

    Create the base of the project with view engine ejs.

    express --view=ejs myapp

    After this command it will create a directory with the base of the project, after it is access and install the generated dependencies.

    npm install

    View engine available

    --view = (dust|ejs|hbs|hjs|jade|pug|twig|vash) (defaults to jade)

    If you do not set --view it creates with the jade view engine as default.

    To create without a defined view, use static html

    express -no--view myapp

    Example

    Answering your question, you do not add the generator to the project, it actually creates. And because of its image there is no two package.json and only one other is lock that stores and locks the versions of each of the installed dependencies. The rest is in the Express generator

        
    05.08.2018 / 09:35