-
-
Notifications
You must be signed in to change notification settings - Fork 263
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
npm run scripts on Windows #44
Comments
Thanks for reporting this @pmosconi Need to check how to fix this! Any help on it is very much appreciated if anyone else runs into this 👍 |
For simple scripts the best solution is using cross-env: |
Pmosconi's solution worked for me on Windows. I think the book should be updated to note this for Windows users as I spent about 2 hours trying to figure out what was going on before coming here. I am guessing there are many readers who have been stuck at this part of the book. |
Thank you for confirming @tmstani23 Sorry that you had to go through this trouble ... It's always difficult for me to align all operating systems on a topic. I will fix it! In the end, did you use
or
or both and both worked for you? Thank you again! |
I used:
"test-server": "set TEST_DATABASE=mytestdatabase&& npm start",
"test": "mocha --require @babel/register src/**/*.spec.js"
I haven't tried cross-env. I'm wondering if that's a library or a part of
node?
Thanks for the response. I've really been enjoying the book so far and
learning so much!
Regards,
Timothy Stanislav
…On Tue, Jan 15, 2019 at 7:02 PM Robin Wieruch ***@***.***> wrote:
Thank you for confirming @tmstani23 <https://github.com/tmstani23> Sorry
that you had to go through this trouble ... It's always difficult for me to
align all operating systems on a topic. I will fix it!
In the end, did you use
"test-server": "set TEST_DATABASE=mytestdatabase&& npm start",
"test": "mocha --require @babel/register src/**/*.spec.js"
or
"test-server": "cross-env TEST_DATABASE=mytestdatabase npm start"
or both and both worked for you?
Thank you again!
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#44 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AG3iALTdqL_Lr8PKfmIcucOP4zTRF1HXks5vDno_gaJpZM4Zl2ph>
.
--
Timothy Stanislav
Cell:507-261-9867
Email:[email protected]
|
cross-env is an npm module you have to add to your dev dependencies.
paolo
Da: Tim Stanislav <[email protected]>
Inviato: mercoledì 16 gennaio 2019 14:38
A: the-road-to-graphql/fullstack-apollo-express-postgresql-boilerplate <fullstack-apollo-express-postgresql-boilerplate@noreply.github.com>
Cc: Paolo Mosconi <[email protected]>; Mention <[email protected]>
Oggetto: Re: [the-road-to-graphql/fullstack-apollo-express-postgresql-boilerplate] npm run scripts on Windows (#44)
I used:
"test-server": "set TEST_DATABASE=mytestdatabase&& npm start",
"test": "mocha --require @babel/register src/**/*.spec.js"
I haven't tried cross-env. I'm wondering if that's a library or a part of
node?
Thanks for the response. I've really been enjoying the book so far and
learning so much!
Regards,
Timothy Stanislav
…On Tue, Jan 15, 2019 at 7:02 PM Robin Wieruch ***@***.*** ***@***.***> > wrote:
Thank you for confirming @tmstani23 <https://github.com/tmstani23> Sorry
that you had to go through this trouble ... It's always difficult for me to
align all operating systems on a topic. I will fix it!
In the end, did you use
"test-server": "set TEST_DATABASE=mytestdatabase&& npm start",
"test": "mocha --require @babel/register src/**/*.spec.js"
or
"test-server": "cross-env TEST_DATABASE=mytestdatabase npm start"
or both and both worked for you?
Thank you again!
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#44 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AG3iALTdqL_Lr8PKfmIcucOP4zTRF1HXks5vDno_gaJpZM4Zl2ph>
.
--
Timothy Stanislav
Cell:507-261-9867
Email:[email protected]
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub <#44 (comment)> , or mute the thread <https://github.com/notifications/unsubscribe-auth/AG8cIoaSYry6QtcdpVJDRcsfgEqCVkc9ks5vDysbgaJpZM4Zl2ph> . <https://github.com/notifications/beacon/AG8cIqB2CMV89-G98ZA-VSgWCN4hfqnTks5vDysbgaJpZM4Zl2ph.gif>
|
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.
The text was updated successfully, but these errors were encountered: