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

前端 未结 6 1186
清酒与你
清酒与你 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条回答
  •  猫巷女王i
    2021-01-31 19:39

    As PauloDev says above, this is a Mac/Windows line ending issue. To elaborate, if you are using nvm you'll need to locate your script first (in my case I'm using express-mvc-generator):

    # install dos2unix
    brew install dos2unix
    
    # output the full path of your node version
    which node 
    >> /Users//.nvm/versions/node/v8.0.0/bin/node
    
    # confirm the file path
    cat /Users//.nvm/versions/node/v8.0.0/lib/node_modules/express-mvc-generator/bin/express
    
    # convert the line endings
    sudo dos2unix /Users//.nvm/versions/node/v8.0.0/lib/node_modules/express-mvc-generator/bin/express
    
    # then run your script
    

提交回复
热议问题