Node script executable not working on Mac : env: node\r: No such file or directory

前端 未结 6 1148
清酒与你
清酒与你 2021-01-31 19:10

I have created my node script executable to execute some tasks grunt. On Windows, my node script works fine. But on Mac OS X (Yosemite), it\'s not working.

My node scri

6条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-31 19:37

    There is a problem with newlines in your script. Make sure that #!/usr/bin/env node is followed by \n (unix style) instead of \r\n (windows/dos style). To fix that, use the tr command to remove \r's from your file:

    cat your_script.js | tr -d '\r' > fixed_script.js
    

提交回复
热议问题