执行“ npm start”命令时出错

时间:2020-07-16 16:05:16

标签: npm sass npm-start scss-mixins

我安装了npm并更改了package.json文件,以便在使用npm start时它可以将.scss文件自动编译为css文件。所做的更改如下。

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

但是当我运行“ npm start”命令时,它将返回错误。错误如下。

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\DJ\AppData\Roaming\npm-cache\_logs\2020-07-16T15_52_00_182Z-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\DJ\AppData\Roaming\npm-cache\_logs\2020-07-16T15_52_00_229Z-debug.log

请帮助我解决这个问题, 我想完成我的项目,但是这种错误会困扰我。

1 个答案:

答案 0 :(得分:0)

这是来自 parallelshell 的错误。我们将不得不手动编辑文件以修复此错误

您需要转到文件:

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

然后一切都会好起来