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

前端 未结 7 1901

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:27

    Might be usefull for someone:

    In my case the problem was, that I had Android Studio running. Had to quit it first, then everything worked fine again.

    0 讨论(0)
  • 2021-02-06 22:31

    Might be helpfull:

    sudo launchctl config user path $PATH

    "To take effect might have to restart your machine"

    0 讨论(0)
  • 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).

    0 讨论(0)
  • 2021-02-06 22:40

    I had the same problem and got it resolved by running the command:

    gradle --stop
    
    0 讨论(0)
  • 2021-02-06 22:40

    I stop the gradle daemon by running

    $ ./gradlew --stop
    

    rerun the gradle command and fix it.

    0 讨论(0)
  • 2021-02-06 22:43

    I ran into this same issue attempting to run Gradle tasks that executed commands such as node and npm from the Gradle plugin in Intellij. You can see from the stack trace that the Gradle plugin is attempting to execute external system commands and it is getting errors such as this:

    WARN - nal.AbstractExternalSystemTask - error=2, No such file or directory 
    com.intellij.openapi.externalSystem.model.ExternalSystemException: error=2, No such file or directory
    at org.jetbrains.plugins.gradle.service.project.GradleExecutionHelper.execute(GradleExecutionHelper.java:228)
    

    You can reproduce this error from the command line if you remove the executables (ie node, npm) from the path, which tells me that something about the plugin is not honoring the environment path.

    My Gradle plugin is using the projects gradlew (gradle wrapper version 2.3), so I attempted to point the plugin at a more recent Gradle installation on my system (version 2.10) and it worked.

    I then resolved my issue by regenerating the gradle wrapper for my project and then setting the IntelliJ Gradle plugin to point back to my wrapper.

    I have no idea what the original problem was.

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