Reactjs 调用嵌套的package.json脚本
因此,我有一个package scripts文件夹,其中保存了我在react环境中构建的所有脚本: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
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