Skip to content

npm run scripts on Windows #44

Open
@pmosconi

Description

@pmosconi

npm run scripting syntax is slightly different on Windows due to the underlying shell being used. Usually the default is cmd.exe (the old DOS), even though it is possible to override the default.

The key changes required for the testing scripts (p. 315 of the book) are:
"test-server": "set TEST_DATABASE=mytestdatabase&& npm start", "test": "mocha --require @babel/register src/**/*.spec.js"
In test-server, there is no space between the variable's value and && on purpose otherwise trailing spaces would be added to the value (https://stackoverflow.com/questions/25112510/how-to-set-environment-variables-from-within-package-json-node-js#comment58812038_27090755).
Note that TEST_DATABASE=mytestdatabase && npm start will not work in Linux because && starts another shell where the variable is not defined.

In test, single quote are omitted otherwise * are not expanded, or at leasr I think.

Unfortunately there is no way to define cross environment scripts without using external packages.

Metadata

Metadata

Assignees

No one assigned

    Labels

    WindowsbugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions