eirslett / frontend-maven-plugin

"Maven-node-grunt-gulp-npm-node-plugin to end all maven-node-grunt-gulp-npm-plugins." A Maven plugin that downloads/installs Node and NPM locally, runs NPM install, Grunt, Gulp and/or Karma.
Apache License 2.0
4.26k stars 870 forks source link

SyntaxError: missing ) after argument list error when run gulp task with frontend-maven-plugin #899

Open rasoolghafari opened 4 years ago

rasoolghafari commented 4 years ago

I have this task in gulpfile.js:

gulp.task('sass', async function () {
    log('Compiling Sass --> CSS');

    var sassOptions = {
        outputStyle: 'nested' // nested, expanded, compact, compressed
    };

    return gulp
        .src(config.sass)
        .pipe($.plumber({errorHandler: swallowError}))
        .pipe($.sourcemaps.init())
        .pipe($.sass(sassOptions))
        .pipe($.autoprefixer())
        .pipe($.sourcemaps.write())
        .pipe(gulp.dest(config.tmp + '/css'));
});

when I run this task with gulp sass command, everything is ok, but with frontend-maven-plugin i get this errors:

INFO] --- frontend-maven-plugin:1.9.1:gulp (gulp build) @ webapp ---
[INFO] Running 'gulp.js build' in /var/lib/jenkins/workspace/project

[INFO] /var/lib/jenkins/workspace/project/gulpfile.js:70
[INFO] gulp.task('sass', async function () {
[INFO]                   ^^^^^
[INFO] 
[INFO] SyntaxError: missing ) after argument list
[INFO]     at createScript (vm.js:56:10)
[INFO]     at Object.runInThisContext (vm.js:97:10)
[INFO]     at Module._compile (module.js:549:28)
[INFO]     at Object.Module._extensions..js (module.js:586:10)
[INFO]     at Module.load (module.js:494:32)
[INFO]     at tryModuleLoad (module.js:453:12)
[INFO]     at Function.Module._load (module.js:445:3)
[INFO]     at Module.require (module.js:504:17)
[INFO]     at require (internal/module.js:20:19)
[INFO]     at execute (/var/lib/jenkins/workspace/project/node_modules/gulp/node_modules/gulp-cli/lib/versioned/^4.0.0/index.js:36:18)

This is build section of pom.xml:

<build>    
    <plugins>
        <plugin>
            <groupId>com.github.eirslett</groupId>
            <artifactId>frontend-maven-plugin</artifactId>
            <version>1.9.1</version>
            <configuration>
                <installDirectory>target</installDirectory>
                <nodeVersion>v6.14.4</nodeVersion>
            </configuration>
            <executions>
                <execution>
                    <id>install node and npm</id>
                    <goals>
                        <goal>install-node-and-npm</goal>
                    </goals>
                    <phase>generate-resources</phase>
                </execution>

                <execution>
                    <id>run npm install</id>
                    <goals>
                        <goal>npm</goal>
                    </goals>
                    <configuration>
                        <arguments>install</arguments>
                    </configuration>
                </execution>

                <execution>
                    <id>gulp sass</id>
                    <goals>
                        <goal>gulp</goal>
                    </goals>

                    <configuration>
                        <arguments>sass</arguments>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>
neoxpert commented 4 years ago

I guess the node version used for the frontend plugin (6.14.4) differs from your local installed one and is too old to support the async keyword. As stated here https://developer.mozilla.org/de/docs/Web/JavaScript/Reference/Statements/async_function the first Node.js version supporting it is 7.6.0.

rasoolghafari commented 4 years ago

@neoxpert, you can see nodejs and npm version here:

Screen Shot 2020-05-27 at 7 08 05 PM

neoxpert commented 4 years ago

@rasoolghafari These are the version available within the context of your local environment. But the frontend plugin downloads and installs its own Node.js environment to run the configured goals in.

If the plugin configuration of the pom.xml is still up to date it states that Node.js version 6.14.4 should be used.

        <configuration>
            <installDirectory>target</installDirectory>
            <nodeVersion>v6.14.4</nodeVersion>
        </configuration>

As this is equal to your local NPM version: Might you have just mixed those config entries / versions up? If you want the frontend plugin to download and use the same versions as you do on your environment the config should look like this:

        <configuration>
            <installDirectory>target</installDirectory>
            <nodeVersion>v12.16.3</nodeVersion>
            <npmVersion>v6.14.4</npmVersion>
        </configuration>