简体   繁体   中英

I'm having an issue running multiple npm scripts using "parallel shell" - code: 'ERR_INVALID_ARG_TYPE'

Good day developers, I'm having an issue running multiple npm scripts using parallel shell . Here are the dependencies in my package.json file:

{
  "name": "confusion",
  "version": "1.0.0",
  "description": "This is a website for Ristorante Con Fusion",
  "main": "index.html",
  "scripts": {
    "start": "npm run watch:all",
    "test": "echo \"Error: no test specified\" && exit 1",
    "lite": "lite-server",
    "scss": "node-sass -o css/ css/",
    "watch:scss": "onchange \"css/*.scss\" -- npm run scss",
    "watch:all": "parallelshell \"npm run watch:scss\" \"npm run lite\""
    },
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "lite-server": "^2.3.0",
    "node-sass": "^7.0.1",
    "onchange": "^7.1.0",
    "parallelshell": "^3.0.2"
  },
  "dependencies": {
    "bootstrap": "^4.0.0",
    "bootstrap-social": "^5.1.1",
    "font-awesome": "^4.7.0",
    "jquery": "^3.3.1",
    "popper.js": "^1.12.9"
  }
}

From my npm scripts , it can be observed that the npm start runs the watch:all script which in turn triggers the npm run watch:scss and npm run lite Here is my error after running the npm start command in cmd:

 confusion@1.0.0 start
> npm run watch:all

npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.

> confusion@1.0.0 watch:all
> parallelshell "npm run watch:scss" "npm run lite"

node:internal/fs/utils:671
    throw new ERR_INVALID_ARG_TYPE(propName, ['string', 'Buffer', 'URL'], path);
    ^

TypeError [ERR_INVALID_ARG_TYPE]: The "options.cwd" property must be of type string or an instance of Buffer or URL. Received function wrappedCwd
    at normalizeSpawnArguments (node:child_process:530:11)
    at spawn (node:child_process:693:13)
    at C:\Users\user\Desktop\FSWD\sandbox\Bootstrap4\conFusion\node_modules\parallelshell\index.js:104:17
    at Array.forEach (<anonymous>)
    at Object.<anonymous> (C:\Users\user\Desktop\FSWD\sandbox\Bootstrap4\conFusion\node_modules\parallelshell\index.js:100:6)
    at Module._compile (node:internal/modules/cjs/loader:1105:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12) {
  code: 'ERR_INVALID_ARG_TYPE'
}

I am using node version **v16.15.1

you can use npm-run-all for this instead of parallel shell install npm-run-all by using $ npm install npm-run-all --save-dev then change the srcipt as "watch:all": "npm-run-all --parallel watch:scss lite " Its Working for me :- 在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM