express或express-generator:我需要两者吗? [英] express or express-generator: do i need both?

查看:148
本文介绍了express或express-generator:我需要两者吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

只需探索node.js并遇到express;在npm存储库网站 https://www.npmjs.com/package/express 上,它明确指出安装是

Just exploring node.js and came across express; On the npm repository site https://www.npmjs.com/package/express it clearly states installation is

$ npm install express

但是如果我向下滚动快速入门提及

but if i scroll down the quick start mentions

$ npm install -g express-generator@4

有人可以详细解释发生了什么吗?我搜索并了解了Express v3中两者都捆绑在一起,但是在Express v4中,生成器被拔出了.

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

那么我需要同时安装两者吗?生成器安装会自动表达但不是相反吗?我已经有JS疲劳了,我才刚开始:-(

So do i need to install both? does the generator install express automatically but not the other way around? I have JS fatigue already, and i only just started :-(

补充问题: 然后,为了使事情更加混乱,我看到了另一个问题,问我应该从"npm init"开始并要求express还是"express myApp".现在到底发生了什么,init在哪里出现?

Supplementary Question: Then to confuse matters even further, i saw another question that asks should I start with 'npm init' and require express, or 'express myApp'. What is really going on now, where does init come into it?

更新2017年1月30日 我已经接受了其他人的以下答案,但是我也添加了自己的答案,这是我当时作为一个困惑的完整初学者所追求的.它可能会帮助别人.

Update 30/Jan/2017 I've accepted an answer below from someone else, but I've also added my own answer which is what i was seeking back then as a confused complete beginner. It may help others.

推荐答案

我的理解是:

  • express 软件包是框架,它公开了可以在代码中使用的功能
  • express-generator 包提供了一个实用程序,该实用程序提供了命令行工具,您可以使用该工具来架设您的项目-即创建样板文件夹结构,文件和代码.
  • The express package is the framework that exposes functionalities you can use in your code
  • The express-generator package a utility that provides a command-line tool you can use to scaffold your project - ie create boilerplate folder structure, files and code.

作为样板文件的一部分,是一个 package.json 文件,该文件定义了项目的依赖项-即项目所需的npm软件包.快递包裹在这里列出.

As part of the boiler plate files is a package.json file defining the dependencies for your project - ie npm packages that you will need for your project. The express package is listed there.

了解 npm install 指令(在当前工作目录设置为包含package.json的项目文件夹中运行)会将package.json中列出的所有依赖项安装"到您的项目文件夹中,以使它们可用到您的应用程序,就足够了:

Knowing the npm install instruction (run with current working directory set to project folder containing the package.json) will "install" all dependencies listed in package.json into your project folder to make them available to your application, it would be sufficient to do:

  • npm install express-generator -g
  • npm安装
  • npm install express-generator -g
  • npm install

这篇关于express或express-generator:我需要两者吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆