Problem running parallelshell Nodejs script
Asked Answered
R

3

8

In my package.json file I have the following scripts:

"scripts": {
    "start": "npm run watch:all",
    "test": "echo \"Error: no test specified\" && exit 1",
    "lite": "lite-server",
    "sass": "node-sass -o sass/ css/",
    "watch:sass": "onchange 'sass/*.scss' -- npm run sass",
    "watch:all": "parallelshell 'npm run watch:sass' 'npm run lite'"
  }

Whenever I run my code I got this error message:

 [email protected] start /home/hazem/crs
> npm run watch:all


> [email protected] watch:all /home/hazem/crs
> parallelshell 'npm run watch:sass' 'npm run lite'

child_process.js:422
    throw new ERR_INVALID_ARG_TYPE('options.cwd', 'string', options.cwd);
    ^

TypeError [ERR_INVALID_ARG_TYPE]: The "options.cwd" property must be of type string. Received type function
    at normalizeSpawnArguments (child_process.js:422:11)
    at spawn (child_process.js:537:38)
    at /home/hazem/crs/node_modules/parallelshell/index.js:104:17
    at Array.forEach (<anonymous>)
    at Object.<anonymous> (/home/hazem/crs/node_modules/parallelshell/index.js:100:6)
    at Module._compile (internal/modules/cjs/loader.js:722:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:733:10)
    at Module.load (internal/modules/cjs/loader.js:620:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:560:12)
    at Function.Module._load (internal/modules/cjs/loader.js:552:3)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] watch:all: `parallelshell 'npm run watch:sass' 'npm run lite'`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] watch:all script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/hazem/.npm/_logs/2018-11-24T19_19_24_809Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] start: `npm run watch:all`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/hazem/.npm/_logs/2018-11-24T19_19_24_823Z-debug.log

So, in this case, what could be the problem? is it something wrong with the script? Or a bug in Parallelshell script in nodejs?

Raquelraquela answered 24/11, 2018 at 19:24 Comment(2)
See open issue #67 in the projects github repo.Capetian
@Capetian Appreciate it, fixed!Raquelraquela
R
34

There is a problem with Parallelshell that has to be fixed manually;

go to the file:

node_modules/parallelshell/index.js:105

Then change this line:

cwd: process.versions.node < '8.0.0' ? process.cwd : process.cwd(),

To this:

cwd: parseInt(process.versions.node) < 8 ? process.cwd : process.cwd(),

It's done!

Raquelraquela answered 25/11, 2018 at 12:4 Comment(1)
If you are having trouble finding this line, its on line number 105(index.js).Spurt
P
0

cwd:

parseInt(process.versions.node) < 8 ? process.cwd : process.cwd() 

If you still face problems after doing this, you have to downgrade the version of paralleshell using this line:

sudo npm install --save-dev [email protected]

It worked for me.

Perennial answered 26/4, 2020 at 5:32 Comment(0)
L
-2

It works for me as I have facing similar issues parallelshell 3.2.2 doesnot cope with my node so I have to downgrade it

Longstanding answered 14/8, 2019 at 5:54 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.