Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Reactjs 调用嵌套的package.json脚本_Reactjs_Npm_Nps - Fatal编程技术网

Reactjs 调用嵌套的package.json脚本

Reactjs 调用嵌套的package.json脚本,reactjs,npm,nps,Reactjs,Npm,Nps,因此,我有一个package scripts文件夹,其中保存了我在react环境中构建的所有脚本: const npsUtils = require('nps-utils') module.exports = { scripts: { default: 'react-scripts start', build: 'react-scripts build', test: 'react-scripts test', eject: 'react-scripts e

因此,我有一个package scripts文件夹,其中保存了我在react环境中构建的所有脚本:

const npsUtils = require('nps-utils')

module.exports = {
  scripts: {
    default: 'react-scripts start',
    build: 'react-scripts build',
    test: 'react-scripts test',
    eject: 'react-scripts eject',
    lint: {
      default: 'eslint ./ --ignore-path .gitignore',
      fix: 'yarn run lint -- --fix',
    },
    format: 'prettier --write "{,!(node_modules)/**/}*.js"',
    validate: npsUtils.concurrent.nps('lint', 'format', 'build'),
  },
}
但是,当我尝试调用lint fix脚本时,它总是失败。我的呼叫
纱线开始起绒:修复
总是失败并给出错误

脚本必须解析为字符串。没有可以修改的脚本 从“lint:fix”中解析

那么,如何调用lint fix?

您可以这样做:

scripts: {
  ...
  "lint:default": "eslint ./ --ignore-path .gitignore",
  "lint:fix": "yarn run lint -- --fix",
  ...
}
并称之为:

yarn start lint:fix