NodeJS Child Process EXEC Command Failed with NVM Permission denied OSX

后端 未结 1 1258
挽巷
挽巷 2021-01-28 04:36

I am attempting to launch nvm within a child process in Nodejs on OSX However in doing so, I am getting the following error: /bin/sh: /Users/miker/.nvm/nvm.sh: Permission denied

相关标签:
1条回答
  • 2021-01-28 05:17

    ~/.nvm/nvm.sh is not executable script, it is meant to be "sourced" (not run in a separate shell, but loaded and executed in the current shell context).

    Trying to run it as if it were executable would result in a permission error, because it doesn't have executable permissions.

    I don't know if it's going to work, but try this instead:

    echo $NVM_DIR && source $NVM_DIR/nvm.sh && nvm use VERSION && npm install
    

    You may have to explicitly set the shell option for child_process.exec() to make sure that the command line is run in a "full" shell (like /bin/bash).

    0 讨论(0)
提交回复
热议问题