Search code examples
node.jsnpmgulpwebpackgulp-sass

gulp failed on Jenkins, but succeed on my VM


I am pretty new to npm and nodejs. what does the output mean? How to debug?

some version info:

10:29:33 + echo ==========================+
10:29:33 ==========================+
10:29:33 + which node
10:29:33 /usr/bin/node
10:29:33 + echo ==========================+
10:29:33 ==========================+
10:29:33 + /usr/local/n/versions/node/5.5.0/bin/node --version
10:29:33 v5.5.0
10:29:33 + echo ==========================+
10:29:33 ==========================+
10:29:33 + node -v
10:29:33 v0.10.37
10:29:33 + echo ==========================+
10:29:33 ==========================+
10:29:33 + /usr/local/n/versions/node/5.5.0/bin/npm --version
10:29:33 3.3.12
10:29:33 + echo ==========================+
10:29:33 ==========================+

...

error output:

10:30:42 + /usr/local/n/versions/node/5.5.0/bin/npm run build
10:30:43 
10:30:43 > [email protected] build /tmp/3791.work
10:30:43 > gulp && webpack
10:30:43 
10:30:43 
10:30:43 /tmp/3791.work/gulpfile.js:30
10:30:43 gulp.task( 'sass', () => {
10:30:43                     ^
10:30:43 SyntaxError: Unexpected token )
10:30:43     at Module._compile (module.js:439:25)
10:30:43     at Object.Module._extensions..js (module.js:474:10)
10:30:43     at Module.load (module.js:356:32)
10:30:43     at Function.Module._load (module.js:312:12)
10:30:43     at Module.require (module.js:364:17)
10:30:43     at require (module.js:380:17)
10:30:43     at Liftoff.handleArguments (/tmp/3791.work/node_modules/gulp/bin/gulp.js:116:3)
10:30:43     at Liftoff.<anonymous> (/tmp/3791.work/node_modules/liftoff/index.js:192:16)
10:30:43     at module.exports (/tmp/3791.work/node_modules/flagged-respawn/index.js:17:3)
10:30:43     at Liftoff.<anonymous> (/tmp/3791.work/node_modules/liftoff/index.js:185:9)
10:30:43 
10:30:43 npm ERR! Linux 3.2.0-34-virtual
10:30:43 npm ERR! argv "/usr/local/n/versions/node/5.5.0/bin/node" "/usr/local/n/versions/node/5.5.0/bin/npm" "run" "build"
10:30:43 npm ERR! node v5.5.0
10:30:43 npm ERR! npm  v3.3.12
10:30:43 npm ERR! code ELIFECYCLE
10:30:43 npm ERR! [email protected] build: `gulp && webpack`
10:30:43 npm ERR! Exit status 8

part of gulpfile.js:

 30 gulp.task( 'sass', () => {
 31   config.sass.targets.forEach( target => {
 32     gulp.src( target.src )
 33       .pipe( sass( config.sass.options ) )
 34       .pipe( gulp.dest( target.dest ) );
 35   });
 36 });

Solution

  • The arrow-functions (they are part of es2015) are disabled by default in node 0.10-0.12 and enabled in 5.5

    You have got the error in connection with an unsupported syntax of-arrow functions in node 0.10.

    To put it simply, when you run gulp, then node gulp is run. You showed that which node gives path to node 0.10, so gulp always runs under it.

    Solution

    /usr/local/n/versions/node/5.5.0/bin/node $(which gulp)