Reputation: 509
I am working on a project with a windows machine, and I have a few npm scripts like this:
"start" : "./foo/bar"
When I try to run npm run start
I get this error:
.\foo\bar is not recognized as an internal or external command,
operable program or batch file.
I noticed the forward slash has been flipped to a backslash for windows, but also if I run this command on its own the bash terminal will interrupt them as 'escapes' and return:
bash: .foobar: command not found
The file runs ok in the terminal if I use ./foo/bar
or .\\foo\\bar
but not if I use these in the npm script.
What can I do to have this working in Windows? Furthermore is there a way to write it to be compatible for Win/Mac/Linux?
Upvotes: 4
Views: 1844
Reputation: 2927
It works when you first do a cd
with normal slashes (npm/nodejs seems to resolve this depending on the OS), then you only have to specify the file.
"scripts": {
"not-working": "scripts/another-folder/foo.cmd",
"working": "cd scripts/another-folder && foo.cmd"
},
Upvotes: 1