Wednesday, January 10, 2018

The following gulp task is not working on windows but working on ubuntu

Leave a Comment

The gulp task

/* Run the npm script npm run buildLsdk using gulp */ gulp.task('sdk', function() {   if (process.cwd() != basePath) {     process.chdir('..');     // console.log(process.cwd());   }   spawn('./node_modules/.bin/lb-sdk', ['server/server.js', './client/src/app/shared/sdk', '-q'], {stdio: 'inherit'}); }); 

I am getting the following stack trace but i cannot debug

Error: spawn ./node_modules/.bin/lb-sdk ENOENT     at exports._errnoException (util.js:1022:11)     at Process.ChildProcess._handle.onexit (internal/child_process.js:193:32)     at onErrorNT (internal/child_process.js:359:16)     at _combinedTickCallback (internal/process/next_tick.js:74:11)     at process._tickCallback (internal/process/next_tick.js:98:9)     at Module.runMain (module.js:607:11)     at run (bootstrap_node.js:420:7)     at startup (bootstrap_node.js:139:9)     at bootstrap_node.js:535:3 

I have all the necessary files in node modules too any help is really appreciated.

More reference on the File use above - https://github.com/rahulrsingh09/loopback-Angular-Starter/blob/master/gulpfile.js

2 Answers

Answers 1

I think it's because lb-sdk.cmd is the file you're supposed to run on windows. when I changed the command to the below the error goes away. Please note the windows style directory slashes are different from linux.

gulp.task('sdk', function() { spawn(   '.\\node_modules\\.bin\\lb-sdk.cmd',   [     '.\\server\\server.js',     '.\\client\\src\\app\\shared\\sdk',     '-q'   ], {stdio: 'inherit'} ); }); 

Answers 2

Can you try using basePath when passing server/server.js and ./client/src/app/shared/sdk. Like for example:

spawn(   './node_modules/.bin/lb-sdk',   [     basePath + '/server/server.js',     basePath + '/client/src/app/shared/sdk',     '-q'   ], {stdio: 'inherit'} ); 
If You Enjoyed This, Take 5 Seconds To Share It

0 comments:

Post a Comment