webpackwebpack-cli

pacakge.json script no longer working after webpack upgrade


I've been asked to go through the packages our application is using and update them to the latest versions, one of these was upgrading webpack from version 3.11.0 to 5.70.0 which also meant I had to install webpack-cli at version 4.9.2.

When the application is run it uses the script buildDev which is:

"buildDev": "npm run unsetReadOnly && webpack --env.NODE_ENV=local && ECHO Completed at %TIME% ".

However when this is run I am now getting the error:

 SyntaxError: Invalid regular expression: /(\p{Uppercase_Letter}+|\p{Lowercase_Letter}|\d)(\p{Uppercase_Letter}+)/: Invalid escape
    at pathToArgumentName (C:\tfs\Agility\Branches\AgilityMakeover\Client\Web\AgilityItemViewer\node_modules\webpack\lib\cli.js:67:4)
    at addFlag.....

Upon looking further into it and trying to run the parts individually, I think the error stems from the part:

webpack --env.NODE_ENV=local

With running this I am getting the error:

[webpack-cli] Error: Unknown option '--env.NODE_ENV=local'

I've been trying to look online to see how to fix this and in other forums I've noticed people with similar issues but there did not appear to be a resolution.

Does anyone know how I can fix this? And why does that no longer work in the latest version of webpack?


Solution

  • So it appears the way to fix was to have it as:

    webpack --env NONE_ENV=local instead now rather than

    webpack --env.NODE_ENV=local

    a small but apparently important change