Express or Express Generator: Do I Need Both?

Just exploring node.js and stumbled upon an express; On the npm repository site https://www.npmjs.com/package/express he clearly states that the installation

$ npm install express

but if I scroll down, a quick start mentions

$ npm install -g express-generator@4

Can someone explain in detail what is happening? I googled and understand in express v3 both were connected together, but in express v4 the generator was pulled out.

So do I need to install both? Does the generator install automatically, but not vice versa? I'm already tired of JS, and I just started: - (

Additional question: Then, to confuse the questions even more, I saw another question that asked whether to start with "npm init" and require an expression, or "express myApp". What is really happening now, where does init enter?

Update 30 / Jan / 2017 I accepted the answer below from someone else, but I also added my own answer, and this is what I was looking for as a confused complete newbie then. It may help others.

+4
source share
3 answers

My understanding:

  • Express package framework that provides functions that you can use in your code
  • - , , , , .

package.json, - npm, . - .

npm install ( , , package.json), "" , package.json, , , :

  • npm install express-generator -g
  • npm install
+3

'express' v4 Windows. , 3 .

0) cmd

1) - ;

npm install -g express-generator

2) ,

express myApp

3) cd myApp, package.json (+ app.js )

4) , "express" (+ , package.json)

npm install

: , 4) javascript, -, ; , 2), cmd -, 1).

, npm init package.json, , npm init -y package.json , .

/, npm init, npm install --save express, , -save . json.

, -, -, . , , 3 , , 3 .

+1

, - -, , , , , - .

.

In V4, the generator is not tied to an expression, and you need to load two separate modules.

0
source

Source: https://habr.com/ru/post/1664747/


All Articles