NPM script under cygwin/windows: the syntax of the command is incorrect

后端 未结 1 1487
[愿得一人]
[愿得一人] 2020-12-21 05:03

I am running Node 6.9.5 and NPM 3.10.10 on a Windows 7 machine. My terminal is Cygwin 2.877.

If I try to run the following in Cygwin, it works fine:

         


        
相关标签:
1条回答
  • 2020-12-21 05:18

    The script are always run in the default windows shell, not cygwin.

    If you want it to run in bash then put this in package.json:

    "scripts": {
        "test": "bash test.sh"
    },
    

    and put this in test.sh:

    #!/bin/bash
    mkdir mydir/mysubdir
    

    Or, as csvan pointed out in the comment, you can use Node scripts instead of shell scripts:

    "scripts": {
        "test": "node test.js"
    },
    

    This approach is even better for cross-platform compatibility.

    See also:

    • Why does `DEBUG=foo node index.js` fails in `scripts` section of `package.json`
    0 讨论(0)
提交回复
热议问题