0

In my package.json I have the following script:

"scripts": {
    "run-trader": "app='member' webpack-dev-server --config ./config/webpack.dev.js "
}

What I achieved with this was that the app variable was passed down as an environment variable to the webpack file, so then inside the file I could do

var app = process.env.app

and get the value member.

Now this doesn't seem to work on windows using the same node and npm version as OSX.

The error that I get is the following:

> app='member' webpack-dev-server --config ./config/webpack.dev.js 

npm : 'app' is not recognized as an internal or external command,
At line:1 char:1
+ npm run-script run-member
+ ~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : NotSpecified: ('app' is not re...ternal command,:String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError

Does anyone know how to fix this? It looks like it is trying to run a script called app.

Note: I have other scripts very similar to this one and they all work on OSX but they don't on windows; the difference is the appname.

Andrew Myers
  • 2,754
  • 5
  • 32
  • 40
Prince Hernandez
  • 3,623
  • 1
  • 10
  • 19

1 Answers1

0

I think cross-env this lib would help you.

Change your script:

cross-env app=member webpack-dev-server --config ./config/webpack.dev.js 

It should work.

Chen-Tai
  • 3,435
  • 3
  • 21
  • 34