legacy-knowledge-base
公開されました Jul. 2, 2025

無効なリンクが原因で nodejs のダウンロードが失敗する

written-by

Zalán Szakolci

How To articles are not official guidelines or officially supported documentation. They are community-contributed content and may not always reflect the latest updates to Liferay DXP. We welcome your feedback to improve How To articles!

While we make every effort to ensure this Knowledge Base is accurate, it may not always reflect the most recent updates or official guidelines.We appreciate your understanding and encourage you to reach out with any feedback or concerns.

legacy-article

learn-legacy-article-disclaimer-text

問題

  • Gradle v.4 + Workspace を使用すると、障害が発生する場合があります。 関連するスタックトレースの例外は次のとおりです。

    > Task :downloadNode FAILED
    Trying to download http://mirrors.lax.liferay.com/nodejs.org/dist/v10.15.1/node-v10.15.1-linux-x64.tar.gz to /home/jenkins/.liferay/mirrors/nodejs.org/dist/v10.15.1/node-v10.15.1-linux-x64.tar.gz.tmp
    Trying to download http://nodejs.org/dist/v10.15.1/node-v10.15.1-linux-x64.tar.gz to /home/jenkins/.liferay/mirrors/nodejs.org/dist/v10.15.1/node-v10.15.1-linux-x64.tar.gz.tmp
    FAILURE: Build failed with an exception.
    * What went wrong:
    Execution failed for task ':downloadNode'.
    > Redirection detected from http to https. Protocol switch unsafe, not allowed.

Environment

  • Gradle v.4 + ワークスペース
  • Liferay DXP 7.0+

解決策

  • 回避策として、 build.gradle に以下を適用します。
    import com.liferay.gradle.util.OSDetector
    
    buildscript {
     dependencies {
      classpath group: "com.liferay", name: "com.liferay.gradle.util", version: "1.0.34"
     }
     repositories {
      mavenCentral()
     }
    }
    
    allprojects {
     plugins.withId("com.liferay.node") {
      def nodeArch
      def nodeExt
      def nodeOS
     
      if (OSDetector.getBitmode().equals("32")) 
          nodeArch = "x86"
      else
          nodeArch = "x64"
    
      if (OSDetector.isWindows()) 
          nodeExt = "zip"
      else
          nodeExt = "tar.gz"
    
      if (OSDetector.isApple()) 
          nodeOS = "darwin";
      else if (OSDetector.isWindows()) 
          nodeOS = "win";
      else
          nodeOS = "linux"
     
      node {
          nodeUrl = "https://nodejs.org/dist/v${nodeVersion}/node-v${nodeVersion}-${nodeOS}-${nodeArch}.${nodeExt}"
      }
     }
    }

追加情報

  • nodejs.com からのダウンロードが http から> https に切り替わる方法が変更されました。 この修正は、Gradle v.5 + 最新のワークスペース プラグイン バージョンに対して既に適用されています。 ただし、Gradle v.4 + Liferay Workspace プラグイン バージョン 2.1.5 以下を使用しているお客様は、 前述の build.gradle 回避策を使用する必要があります。
    この回避策は、ノード プラグインによって通常自動的に計算される nodeURL プロパティをオーバーライドすることで問題を解決します。

did-this-article-resolve-your-issue

legacy-knowledge-base