在公司限制使用代理上网的情况下,采用https代理,如下成功安装webpack:
npm配置的用户配置如下:
-------------------------
文件路径:C:\Users\xxx\.npmrc
------------------------- prefix=D:\programs\node-v12.14.0-win-x64\node-global cache=D:\programs\node-v12.14.0-win-x64\node-cache proxy=http://myaccount:[email protected]_url:8080/ https-proxy=http://myaccount:[email protected]_url:8080/ registry=https://registry.npmjs.org/ strict-ssl=false cert="-----BEGIN CERTIFICATE-----\nMIICiTCCAfKgAwIBAgIERVh2WTANBgkqhkiG9w0BAQQFADCBiDELMAkGA1UEBhMC\nSlAxGDAWBgNVBAMTD2JjLWdhdGUub2tpLmNvbTEjMCEGA1UEChQaQlBSICYgSVQg\nUGxhbm5pbmcgRGl2aXNpb24xJjAkBgNVBAsTHU9raSBFbGVjdHJpYyBJbmR1c3Ry\neSBDby5MdGQuMRIwEAYDVQQHEwlNaW5hdG8ta3UwHhcNMDYxMTEzMTM0MjQ5WhcN\nMzYxMjMxMTM0MjQ5WjCBiDELMAkGA1UEBhMCSlAxGDAWBgNVBAMTD2JjLWdhdGUu\nb2tpLmNvbTEjMCEGA1UEChQaQlBSICYgSVQgUGxhbm5pbmcgRGl2aXNpb24xJjAk\nBgNVBAsTHU9raSBFbGVjdHJpYyBJbmR1c3RyeSBDby5MdGQuMRIwEAYDVQQHEwlN\naW5hdG8ta3UwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBALZgNZ9s2L8J7yUG\ncOnv5Y13DZfddGmSLtuglL0aXebxM3gTaxyUhyWMRlbrkgk421me4TcnuGTsvQGl\nsgR3bnqKWPmQc9hfUpkevW3lDQd+SKPffAkDSfCcM+L64UnGSfXHCG3Yl5RE18mG\nqbJLb/D+Hy7gCVnpydbWkX43MBV5AgMBAAEwDQYJKoZIhvcNAQEEBQADgYEAQdVi\nkMV3fh0ApYR3hdyVRPPyztBA+hYn32NVsOuetrU56iMMWq1kuVokOvTl2PFs0uFo\nr3gogcIQsbXOJQANXeTEvttnOZFCDh1RWmDNFNLxfWuhZtx7W+MbS3ypN6GVrjkC\nB/uqGY4QTEGQxniJSRhYXogR7y5TYDdVSlapi7M=\n-----END CERTIFICATE-----" -------------------------
cert是公司的https证书(PEM格式);
严格认证改为false;
日志:
----------------------------[log_ webpack安装_开始] C:\Users\xxx>npm install -g webpack D:\programs\node-v12.14.0-win-x64\node-global\webpack -> D:\programs\node-v12.14.0-win-x64\node-global\node_modules\webpack\bin\webpack.js npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules\webpack\node_modules\fsevents): npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"}) + [email protected] added 322 packages from 197 contributors in 667.033s ----------------------------[log_ webpack安装_结束]
查看npm-global路径(node-v12.14.0-win-x64\node-global),已经多了webpack模块。
原文地址:https://www.cnblogs.com/m160331/p/12085075.html
时间: 2024-11-12 02:51:10