【问题标题】:where do I specify the node version in LifeRay studio project?在 LifeRay 工作室项目中,我在哪里指定节点版本?
【发布时间】:2019-12-16 20:34:02
【问题描述】:

我有一个使用 Angular 应用程序作为客户端的 portlet 项目。构建脚本是一个通过 ExecuteGulpTask 插件执行 npmInstall 任务的 gradle 脚本。问题是 npmInstall 任务永远运行。我已经在 DOS 控制台中单独完成了“npm install”,而 Node 10.16.0 没有错误。我发现,插件正在执行的节点版本是节点版本 5.5.0(在生成的“构建”文件夹中)。不知道这个版本来自哪里,我猜是导致问题的原因。我在哪里配置 Gulp Gradle 插件使用的节点版本?还是portlet项目中Node的配置? (我什至在 Liferay developer studio 3.5 IDE 中都找不到它)。我的 PATH 变量有节点 10.16.0、npm 6.13.4、角度 7.1.3

这些是脚本

build.gradle

        buildscript {
            dependencies {
                classpath group: "com.liferay", name: "com.liferay.gradle.plugins", version: "2.0.10"       
            }

            repositories {
                mavenLocal()

                maven {
                    url "https://cdn.lfrs.sl/repository.liferay.com/nexus/content/groups/public"
                }
            }
        }

        apply plugin: "com.liferay.plugin"
        apply plugin: "com.liferay.gulp"

        import com.liferay.gradle.plugins.gulp.ExecuteGulpTask

        task compileTypeScript(type: ExecuteGulpTask)

        compileTypeScript {
            dependsOn npmInstall

            gulpCommand = 'default'
        }

        classes {
            dependsOn compileTypeScript
        }

        dependencies {
            compileOnly group: "com.liferay.portal", name: "com.liferay.portal.kernel", version: "2.0.0"
            compileOnly group: "javax.portlet", name: "portlet-api", version: "2.0"
            compileOnly group: "org.osgi", name: "org.osgi.compendium", version: "5.0.0"
        }

package.json

    "dependencies": {
        "@angular/animations": "^4.3.6",
        "@angular/common": "^4.3.6",
        "@angular/compiler": "^4.3.6",
        "@angular/compiler-cli": "^4.3.6",
        "@angular/core": "^4.3.6",
        "@angular/forms": "^4.3.6",
        "@angular/http": "^4.3.6",
        "@angular/platform-browser": "^4.3.6",
        "@angular/platform-browser-dynamic": "^4.3.6",
        "@angular/platform-server": "^4.3.6",
        "@angular/router": "^4.3.6",
        "@angular/upgrade": "~2.2.1",
        "@ng-bootstrap/ng-bootstrap": "^1.0.0-beta.5",
        "angular2-in-memory-web-api": "0.0.21",
        "angularfire2": "^4.0.0-rc.2",
        "bootstrap": "^3.3.7",
        "core-js": "^2.4.1",
        "ie-shim": "^0.1.0",
        "promise-polyfill": "6.0.2",
        "reflect-metadata": "^0.1.10",
        "rxjs": "^5.4.3",
        "zone.js": "~0.7.7"
      },
      "devDependencies": {
        "@types/node": "^6.0.48",
        "angular2-router-loader": "^0.3.4",
        "angular2-template-loader": "^0.6.0",
        "awesome-typescript-loader": "^3.2.3",
        "css-loader": "^0.25.0",
        "gulp": "~3.9.1",
        "raw-loader": "^0.5.1",
        "source-map-support": "^0.4.16",
        "to-string-loader": "^1.1.4",
        "typescript": "^2.4.2",
        "webpack": "2.2.1",
        "webpack-merge": "^3.0.0"
      },

Gulpfile.js

    var gulp = require("gulp");
    var gutil = require("gulp-util");
    var webpack = require("webpack");

    gulp.task("default", function(callback) {
        // run webpack
        webpack(require('./webpack.config.js'), function(err, stats) {      
            if (err)
                throw new gutil.PluginError("webpack:build", err);
            gutil.log("[webpack:build]", stats.toString({
                colors : true
            }));
            callback();
        });
    });

【问题讨论】:

    标签: node.js angular gradle gulp


    【解决方案1】:

    将此配置添加到您的 build.gradle 文件中:

    node {
        version = '10.15.1'
        npmVersion = '6.4.1'
    
        // If true, it will download node using above parameters.
        // If false, it will try to use globally installed node.
        download = false
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-03-21
      • 1970-01-01
      • 2020-02-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多