NPM Parallelshell 无法工作,显示错误(已解决)。

问题描述 投票:0回答:1

我试图按照课程中描述的那样,同时运行npm lite server和onchange for scss,但却得到了一个错误......试着用package.json运行npm start,其中包含的脚本为-。

"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\""
  }

我没有正常工作,而是得到了以下错误----------。

> [email protected] start F:\Courses\Full-Stack Web Development\Bootstrap4\conFusion
> npm run watch:all


> [email protected] watch:all F:\Courses\Full-Stack Web Development\Bootstrap4\conFusion
> parallelshell "npm run watch:scss" "npm run lite"

child_process.js:430
    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 function wrappedCwd
    at normalizeSpawnArguments (child_process.js:430:11)
    at spawn (child_process.js:546:13)
    at F:\Courses\Full-Stack Web Development\Bootstrap4\conFusion\node_modules\parallelshell\index.js:104:17
    at Array.forEach (<anonymous>)
    at Object.<anonymous> (F:\Courses\Full-Stack Web Development\Bootstrap4\conFusion\node_modules\parallelshell\index.js:100:6)
    at Module._compile (internal/modules/cjs/loader.js:1176:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1196:10)
    at Module.load (internal/modules/cjs/loader.js:1040:32)
    at Function.Module._load (internal/modules/cjs/loader.js:929:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12) {
  code: 'ERR_INVALID_ARG_TYPE'
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] watch:all: `parallelshell "npm run watch:scss" "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!     C:\Users\Ankur\AppData\Roaming\npm-cache\_logs\2020-05-27T07_16_54_990Z-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!     C:\Users\Ankur\AppData\Roaming\npm-cache\_logs\2020-05-27T07_16_55_176Z-debug.log

如何删除这个错误...?

npm npm-scripts npm-package
1个回答
1
投票

当我在搜索解决方案时,我在另一个帖子中找到了这个问题的解决方案--------。

运行parallelshell Nodejs脚本的问题

进入文件。

node_modules/parallelshell/index.js:105

然后把这行改成:

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

改成这样

cwd: parseInt(process.versions.node) < 8 ? process.cwd : process.cwd(),
© www.soinside.com 2019 - 2024. All rights reserved.