0%

webpack安装(own)

2018年5月4日 下午3:49

init过程
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
localhost:Front-end czh$ 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: (Front-end)
Sorry, name can no longer contain capital letters.
name: (Front-end) front-end
version: (1.0.0)
description: programing前端代码
entry point: (index.js)
test command:
git repository: (https://github.com/czh55/Front-end.git)
keywords:
author: czh
license: (ISC)
About to write to /Users/czh/front-end/Front-end/package.json:

{
"name": "front-end",
"version": "1.0.0",
"description": "programing前端代码",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git+https://github.com/czh55/Front-end.git"
},
"author": "czh",
"license": "ISC",
"bugs": {
"url": "https://github.com/czh55/Front-end/issues"
},
"homepage": "https://github.com/czh55/Front-end#readme"
}


Is this ok? (yes)

安装webpack过程

  1. 全局安装webpack
    1. npm install webpack -g
  2. 生产环境安装webpack
    1. npm install webpack@1.15.0 --save-dev
  3. 报错

解决报错问题

  1. 全局安装的webpack默认安装版本是4.6.0,版本太高,要卸载
  2. 我们要指定全局安装为2.6.1
  3. 参考安装webpack后,执行webpack -v命令时报错:SyntaxError: Block-sc-zero-51CTO博客
  4. npm uninstall webpack -g
  5. npm install webpack@2.6.1 -g --registry=https://registry.npm.taobao.org
  6. webpack -v

最后的结果