在Mac终端执行npm install webpack -g
进行全局安装webpack出现如下错误
0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli '/usr/local/bin/node',
1 verbose cli '/usr/local/bin/npm',
1 verbose cli 'install',
1 verbose cli 'webpack',
1 verbose cli '-g'
1 verbose cli ]
2 info using npm@6.14.5
3 info using node@v14.4.0
4 verbose npm-session d534de7a0185d9d4
5 silly install loadCurrentTree
6 silly install readGlobalPackageData
7 http fetch GET 200 https://registry.npmjs.org/webpack 2351ms
8 silly pacote tag manifest for webpack@latest fetched in 2394ms
9 timing stage:loadCurrentTree Completed in 2472ms
10 silly install loadIdealTree
11 silly install cloneCurrentTreeToIdealTree
12 timing stage:loadIdealTree:cloneCurrentTree Completed in 0ms
13 silly install loadShrinkwrap
14 timing stage:loadIdealTree:loadShrinkwrap Completed in 2ms
15 silly install loadAllDepsIntoIdealTree
16 silly resolveWithNewModule webpack@4.44.1 checking installable status
17 http fetch GET 304 https://registry.npmjs.org/@webassemblyjs%2fwasm-edit 250ms (from cache)
18 silly pacote version manifest for @webassemblyjs/wasm-edit@1.9.0 fetched in 254ms
19 silly resolveWithNewModule @webassemblyjs/wasm-edit@1.9.0 checking installable status
20 http fetch GET 304 https://registry.npmjs.org/json-parse-better-errors 219ms (from cache)
21 silly pacote range manifest for json-parse-better-errors@^1.0.2 fetched in 223ms
22 silly resolveWithNewModule json-parse-better-errors@1.0.2 checking installable status
23 http fetch GET 304 https://registry.npmjs.org/@webassemblyjs%2fhelper-module-context 591ms (from cache)
24 silly pacote version manifest for @webassemblyjs/helper-module-context@1.9.0 fetched in 595ms
25 silly resolveWithNewModule @webassemblyjs/helper-module-context@1.9.0 checking installable status
26 http fetch GET 304 https://registry.npmjs.org/@webassemblyjs%2fwasm-parser 631ms (from cache)
27 silly pacote version manifest for @webassemblyjs/wasm-parser@1.9.0 fetched in 637ms
28 silly resolveWithNewModule @webassemblyjs/wasm-parser@1.9.0 checking installable status
29 http fetch GET 304 https://registry.npmjs.org/chrome-trace-event 640ms (from cache)
30 silly pacote range manifest for chrome-trace-event@^1.0.2 fetched in 644ms
31 silly resolveWithNewModule chrome-trace-event@1.0.2 checking installable status
32 http fetch GET 304 https://registry.npmjs.org/eslint-scope 645ms (from cache)
33 silly pacote range manifest for eslint-scope@^4.0.3 fetched in 651ms
34 silly resolveWithNewModule eslint-scope@4.0.3 checking installable status
35 http fetch GET 200 https://registry.npmjs.org/loader-utils 201ms
36 http fetch GET 200 https://registry.npmjs.org/acorn 791ms
37 silly pacote range manifest for loader-utils@^1.2.3 fetched in 209ms
38 silly resolveWithNewModule loader-utils@1.4.0 checking installable status
39 silly pacote range manifest for acorn@^6.4.1 fetched in 800ms
40 silly resolveWithNewModule acorn@6.4.1 checking installable status
41 http fetch GET 304 https://registry.npmjs.org/memory-fs 210ms (from cache)
42 silly pacote range manifest for memory-fs@^0.4.1 fetched in 215ms
43 silly resolveWithNewModule memory-fs@0.4.1 checking installable status
44 http fetch GET 304 https://registry.npmjs.org/micromatch 220ms (from cache)
45 silly pacote range manifest for micromatch@^3.1.10 fetched in 226ms
46 silly resolveWithNewModule micromatch@3.1.10 checking installable status
47 http fetch GET 304 https://registry.npmjs.org/mkdirp 224ms (from cache)
48 silly pacote range manifest for mkdirp@^0.5.3 fetched in 229ms
49 silly resolveWithNewModule mkdirp@0.5.5 checking installable status
50 http fetch GET 304 https://registry.npmjs.org/neo-async 196ms (from cache)
51 silly pacote range manifest for neo-async@^2.6.1 fetched in 200ms
52 silly resolveWithNewModule neo-async@2.6.2 checking installable status
53 http fetch GET 304 https://registry.npmjs.org/node-libs-browser 207ms (from cache)
54 silly pacote range manifest for node-libs-browser@^2.2.1 fetched in 210ms
55 silly resolveWithNewModule node-libs-browser@2.2.1 checking installable status
56 http fetch GET 304 https://registry.npmjs.org/schema-utils 202ms (from cache)
57 silly pacote range manifest for schema-utils@^1.0.0 fetched in 208ms
58 silly resolveWithNewModule schema-utils@1.0.0 checking installable status
59 http fetch GET 304 https://registry.npmjs.org/tapable 207ms (from cache)
60 silly pacote range manifest for tapable@^1.1.3 fetched in 211ms
61 silly resolveWithNewModule tapable@1.1.3 checking installable status
62 http fetch GET 304 https://registry.npmjs.org/ajv 1148ms (from cache)
63 silly pacote range manifest for ajv@^6.10.2 fetched in 1156ms
64 silly resolveWithNewModule ajv@6.12.3 checking installable status
65 http fetch GET 200 https://registry.npmjs.org/watchpack 198ms
66 silly pacote range manifest for watchpack@^1.7.4 fetched in 202ms
67 silly resolveWithNewModule watchpack@1.7.4 checking installable status
68 http fetch GET 304 https://registry.npmjs.org/enhanced-resolve 1225ms (from cache)
69 http fetch GE
解决方式
在mac下依赖包要写入系统重要文件夹里,需要先获取root权限(如果不获取root权限会出错如上方的报错信息),所以终端需执行如下命令:
sudo npm install webpack -g
sudo
命令是获取管理员权限
执行后会出现小钥匙,输入你的密码然后再按回车就可以了