node js 中express 所遇到的问题

本文档详细记录了使用Node.js创建新项目的步骤,包括项目目录的搭建、初始化生成package.json文件及Express框架的安装过程。通过命令行操作演示了如何配置基本的项目结构,并指出了Express安装的具体细节。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >


E:\nodejs\helloword>

E:\nodejs\helloword>cd ..

E:\nodejs>mkdir test

E:\nodejs>cd test

E:\nodejs\test>npm init
This utility will walk you through creating a package.json file.
It only covers the most common items, and tries to guess sensible defaults.

See `npm help json` for definitive documentation on these fields
and exactly what they do.

Use `npm install <pkg> --save` afterwards to install a package and
save it as a dependency in the package.json file.

Press ^C at any time to quit.
name: (test) test
version: (1.0.0) 1.0.0
description: test
entry point: (index.js)
test command:
git repository:
keywords:
author:
license: (ISC) MIT
About to write to E:\nodejs\test\package.json:

{
  "name": "test",
  "version": "1.0.0",
  "description": "test",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "MIT"
}


Is this ok? (yes) yes

E:\nodejs\test>npm install --save express

提示:express 必须安装在项目目录的根目录下,也就是说每个项目都要安装express,然后再安装依赖express的其他模块 比如cookie等。

npm WARN package.json test@1.0.0 No repository field.
npm WARN package.json test@1.0.0 No README data
express@4.14.0 node_modules\express
├── escape-html@1.0.3
├── array-flatten@1.1.1
├── utils-merge@1.0.0
├── cookie-signature@1.0.6
├── encodeurl@1.0.1
├── content-type@1.0.2
├── parseurl@1.3.1
├── cookie@0.3.1
├── methods@1.1.2
├── path-to-regexp@0.1.7
├── range-parser@1.2.0
├── etag@1.7.0
├── vary@1.1.0
├── content-disposition@0.5.1
├── merge-descriptors@1.0.1
├── fresh@0.3.0
├── serve-static@1.11.1
├── depd@1.1.0
├── qs@6.2.0
├── on-finished@2.3.0 (ee-first@1.1.1)
├── finalhandler@0.5.0 (unpipe@1.0.0, statuses@1.3.0)
├── debug@2.2.0 (ms@0.7.1)
├── proxy-addr@1.1.2 (forwarded@0.1.0, ipaddr.js@1.1.1)
├── type-is@1.6.13 (media-typer@0.3.0, mime-types@2.1.11)
├── accepts@1.3.3 (negotiator@0.6.1, mime-types@2.1.11)
└── send@0.14.1 (destroy@1.0.4, statuses@1.3.0, ms@0.7.1, mime@1.3.4, http-errors@1.5.0)

E:\nodejs\test>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值