欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

Webpack-cli安装成功后查看webpack -v报错案例详解

程序员文章站 2022-07-02 22:15:46
目录问题1. 安装webpack webpack-clinpm install -g webpack webpack-cli2. 查看webpack 版本webpack -v报错/usr/local/...

问题

1. 安装webpack webpack-cli

npm install -g webpack webpack-cli

Webpack-cli安装成功后查看webpack -v报错案例详解

2. 查看webpack 版本

webpack -v

报错

/usr/local/lib/node_modules/webpack/lib/cli.js:66
                        .replace(
                        ^

syntaxerror: invalid regular expression: /(\p{uppercase_letter}+|\p{lowercase_letter}|\d)(\p{uppercase_letter}+)/: invalid escape
    at pathtoargumentname (/usr/local/lib/node_modules/webpack/lib/cli.js:66:4)
    at addflag (/usr/local/lib/node_modules/webpack/lib/cli.js:170:16)
    at traverse (/usr/local/lib/node_modules/webpack/lib/cli.js:243:21)
    at traverse (/usr/local/lib/node_modules/webpack/lib/cli.js:299:23)
    at traverse (/usr/local/lib/node_modules/webpack/lib/cli.js:248:24)
    at object.getarguments (/usr/local/lib/node_modules/webpack/lib/cli.js:308:2)
    at object.<anonymous> (/usr/local/lib/node_modules/webpack-cli/lib/utils/cli-flags.js:245:30)
    at module._compile (/usr/local/lib/node_modules/webpack-cli/node_modules/v8-compile-cache/v8-compile-cache.js:192:30)
    at object.module._extensions..js (internal/modules/cjs/loader.js:665:10)
    at module.load (internal/modules/cjs/loader.js:566:32)

解决

1. 查看node版本

node -v
v9.11.2

发现node版本 不是最新的,官网下载安装最新版本的node(lts)

node -v
v14.15.0

2. 升级npm

npm i -g npm

3. 查看webpack版本

webpack -v

webpack-cli 4.2.0

webpack 5.4.0

到此这篇关于webpack-cli安装成功后查看webpack -v报错案例详解的文章就介绍到这了,更多相关webpack-cli安装成功后查看webpack -v报错内容请搜索以前的文章或继续浏览下面的相关文章希望大家以后多多支持!

相关标签: webpack -v