webpack:无法读取未定义的属性“匹配" [英] webpack: Cannot read property 'match' of undefined

查看:88
本文介绍了webpack:无法读取未定义的属性“匹配"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用 npm 安装了 webpack(Symfony encore),如下所示:

I have installed webpack (Symfony encore) using npm as follows:

sudo npm install -g @symfony/webpack-encore --save-dev

我从 /var/www/project 运行这个

在处理 Windows 主机/Linux 客户机时,由于包管理器和共享文件夹的问题,我需要全局安装.

I was required to install globally due to issues with package managers and shared folders when dealing with Windows host / Linux guest.

我无法将 webpack (node_modules) 安装在 /var/www/project 所在的同一目录(或在其下)

I cannot install webpack (node_modules) in the same directory (or under it) as the /var/www/project

所以我的 package.json 文件看起来像这样:

So my package.json file looks like this:

{
  "name": "test",
    "version": "1.0.0",
  "description": "This is a test",
  "main": "index.js",
  "dependencies": {},
  "devDependencies": {
    "@symfony/webpack-encore": "^0.15.0"
  },
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "Alex",
    "license": "MIT"
}

我使用这个从 /var/www/project 运行 encore

I run encore from /var/www/project using this

/usr/local/bin/encore dev

作为回报,我得到了这个可爱的输出:

I get this lovely output in return:

Running webpack ...

  TypeError: Cannot read property 'match' of undefined

  - index.js:125 parse
    [lib]/[webpack-encore]/[yargs-parser]/index.js:125:12

  - index.js:761 Function.Parser.detailed
    [lib]/[webpack-encore]/[yargs-parser]/index.js:761:10

  - yargs.js:938 Object.Yargs.self._parseArgs
    [lib]/[webpack-encore]/[yargs]/yargs.js:938:27

  - yargs.js:927 Object.get [as argv]
    [lib]/[webpack-encore]/[yargs]/yargs.js:927:19

  - index.js:725 Object.configureRuntimeEnvironment
    [lib]/[@symfony]/webpack-encore/index.js:725:54

  - index.js:770 Proxy.parameters
    [lib]/[@symfony]/webpack-encore/index.js:770:45

  - webpack.config.js:3 Object.<anonymous>
    /var/www/project/webpack.config.js:3:8

  - module.js:573 Module._compile
    module.js:573:30

  - module.js:584 Object.Module._extensions..js
    module.js:584:10

  - module.js:507 Module.load
    module.js:507:32

我错过了什么?

推荐答案

简单回答就运行

rm -rf package-lock.json

这篇关于webpack:无法读取未定义的属性“匹配"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆