【问题标题】:NPM Parallelshell not working, showing errorNPM Parallelshell 不工作,显示错误
【发布时间】:2020-09-14 04:20:29
【问题描述】:

我试图按照我的课程中的描述一起运行 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\""
  }

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

> confusion@1.0.0 start F:\Courses\Full-Stack Web Development\Bootstrap4\conFusion
> npm run watch:all


> confusion@1.0.0 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! confusion@1.0.0 watch:all: `parallelshell "npm run watch:scss" "npm run lite"`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the confusion@1.0.0 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! confusion@1.0.0 start: `npm run watch:all`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the confusion@1.0.0 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】:

    在寻找解决方案时,我在另一篇文章中找到了该问题的解决方案 -

    Problem running parallelshell Nodejs script

    转到文件:

    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(),
    

    【讨论】:

    • 另一种选择是降级到 3.0.1(遵循相同的课程,因此不想切换到另一个库)
    猜你喜欢
    • 1970-01-01
    • 2018-12-29
    • 1970-01-01
    • 1970-01-01
    • 2021-04-19
    • 1970-01-01
    • 2015-10-11
    • 2021-03-22
    • 1970-01-01
    相关资源
    最近更新 更多