Gradle “… occurred starting process 'command 'npm''” on Mac

前端 未结 7 1904

I have MacOS with IntelliJ Idea installed. I\'m using Gradle (gradle-2.4) for building the project. I have NodeJS and NPM installed on the Mac and available from the shell.

7条回答
  •  遥遥无期
    2021-02-06 22:34

    The answer is this is trivial it turns out. Solution is applicable to ANY application.

    The reason for the error is that none of the visual apps on Mac OS X use a user shell so whatever you have in your local profile settings such as ~/.bash_profile simply does not take when Studio is launched. There is a good workaround:

    1. from terminal, go to this directory or where ever your Studio app (or any other app) is installed:
    cd /Applications/Android Studio.app/Contents/MacOS
    
    1. Move the studio executable to studio_app (or whatever is your executable name)
    mv $executable$ $executable$_app
    
    1. Create a new text file, call it $executable$, and populate it like this. Here I am using my bash_profile.
    #!/bin/sh    
    . ~/.bash_profile
    logger "`dirname \"$0\"`/$executable$_app"
    exec "`dirname \"$0\"`/$executable$_app" $@
    
    1. Close the studio file. From shell change permissions:
    chmod +x $executable$
    

    And that is it. Relaunch Studio app normally and now it has inherited all your settings from bash_profile, including path to node etc.

    Substitute $executable$ with the name of your exe file. For Android Studio it would be just studio. For IntelliJ it should be just intellij (double check).

提交回复
热议问题