ecomfe / reskript

一个帮助开发React应用的全功能命令行套件
https://reskript.dev
MIT License
213 stars 33 forks source link

提交代码报错 #263

Closed believeZJP closed 2 years ago

believeZJP commented 2 years ago

Command failed, you may submit a issue to https://github.com/ecomfe/reskript/issues/new npm ERR! code ELIFECYCLE npm ERR! errno 99 npm ERR! aaaa@1.0.0 lint-staged: skr lint --staged --fix --auto-stage npm ERR! Exit status 99 npm ERR! npm ERR! Failed at the aaaa@1.0.0 lint-staged 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! /Users/macintosh/.npm/_logs/2022-02-21T09_09_46_547Z-debug.log husky > pre-commit hook failed (add --no-verify to bypass)

0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node', '/usr/local/bin/npm', 'run', 'lint-staged' ]
2 info using npm@6.14.15
3 info using node@v14.18.0
4 verbose run-script [ 'prelint-staged', 'lint-staged', 'postlint-staged' ]
5 info lifecycle aaaa@1.0.0~prelint-staged: aaaa@1.0.0
6 info lifecycle aaaa@1.0.0~lint-staged: aaaa@1.0.0
7 warn lifecycle The node binary used for scripts is /var/folders/nz/f72njj216_n98jy1b696wxw00000gn/T/yarn--1645434582098-0.11681747820516408/node but npm is using /usr/local/bin/node itself. Use the `--scripts-prepend-node-path` option to include the path for the node binary npm was executed with.
8 verbose lifecycle aaaa@1.0.0~lint-staged: unsafe-perm in lifecycle true
9 verbose lifecycle aaaa@1.0.0~lint-staged: PATH: /usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/Users/macintosh/Desktop/workspaces/baidu/hec/iot-fe/node_modules/.bin:/var/folders/nz/f72njj216_n98jy1b696wxw00000gn/T/yarn--1645434582098-0.11681747820516408:/Users/macintosh/Desktop/workspaces/baidu/hec/iot-fe/node_modules/.bin:/Users/macintosh/.config/yarn/link/node_modules/.bin:/usr/local/libexec/lib/node_modules/npm/bin/node-gyp-bin:/usr/local/lib/node_modules/npm/bin/node-gyp-bin:/usr/local/bin/node_modules/npm/bin/node-gyp-bin:/usr/local/Cellar/git/2.28.0/libexec/git-core:/Users/macintosh/.autojump/bin:/Users/macintosh/.autojump/bin:/Library/Java/JavaVirtualMachines/jdk1.8.0_291.jdk/Contents/Home/bin:/Users/macintosh/fvm/default/bin:/Library/Frameworks/Python.framework/Versions/3.9/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Applications/VMware Fusion.app/Contents/Public:/Library/Apple/usr/bin:/Users/macintosh/.autojump/bin:/Library/Java/JavaVirtualMachines/jdk1.8.0_291.jdk/Contents/Home/bin:/Users/macintosh/fvm/default/bin:/Library/Frameworks/Python.framework/Versions/3.9/bin:/Applications/Visual Studio Code.app/Contents/Resources/app/bin:/Applications/Visual Studio Code.app/Contents/Resources/app/bin
10 verbose lifecycle aaaa@1.0.0~lint-staged: CWD: /Users/macintosh/Desktop/workspaces/baidu/hec/iot-fe
11 silly lifecycle aaaa@1.0.0~lint-staged: Args: [ '-c', 'skr lint --staged --fix --auto-stage' ]
12 silly lifecycle aaaa@1.0.0~lint-staged: Returned: code: 99  signal: null
13 info lifecycle aaaa@1.0.0~lint-staged: Failed to exec lint-staged script
14 verbose stack Error: aaaa@1.0.0 lint-staged: `skr lint --staged --fix --auto-stage`
14 verbose stack Exit status 99
14 verbose stack     at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:332:16)
14 verbose stack     at EventEmitter.emit (events.js:400:28)
14 verbose stack     at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
14 verbose stack     at ChildProcess.emit (events.js:400:28)
14 verbose stack     at maybeClose (internal/child_process.js:1058:16)
14 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:293:5)
15 verbose pkgid aaaa@1.0.0
16 verbose cwd /Users/macintosh/Desktop/workspaces/baidu/hec/iot-fe
17 verbose Darwin 20.4.0
18 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "lint-staged"
19 verbose node v14.18.0
20 verbose npm  v6.14.15
21 error code ELIFECYCLE
22 error errno 99
23 error aaaa@1.0.0 lint-staged: `skr lint --staged --fix --auto-stage`
23 error Exit status 99
24 error Failed at the aaaa@1.0.0 lint-staged script.
24 error This is probably not a problem with npm. There is likely additional logging output above.
25 verbose exit [ 99, true ]
otakustay commented 2 years ago

试着跑一下SKR_LOGGING=debug skr lint --staged --fix --auto-stage看看输出

believeZJP commented 2 years ago

试着跑一下SKR_LOGGING=debug skr lint --staged --fix --auto-stage看看输出

reskript.config.ts:undefined:undefined ✖ 0:0 Parsing error: "parserOptions.project" has been set for @typescript-eslint/parser. The file does not match your project config: reskript.config.ts. The file must be included in at least one of the projects provided.

25 warnings 1 error

import {configure} from '@reskript/settings';

export default configure(
    'webpack',
    {
        // https://reskript.dev/docs/settings/feature-matrix
        featureMatrix: {
            stable: {},
            dev: {},
        },
        // https://reskript.dev/docs/settings/build
        build: {
            appTitle: 'aaaa',
        },
        // https://reskript.dev/docs/settings/dev-server
        devServer: {
            port: 8788,
            // TODO: 修改后端API代理的配置
            apiPrefixes: ['/api', '/iot-manager'],

        },
    }
)
otakustay commented 2 years ago

在tsconfig.json的include里加一下./*.ts

believeZJP commented 2 years ago

Eslint配置报这个错是需要改什么?

[Error - 7:34:30 PM] ESLint stack trace:
[Error - 7:34:30 PM] Error: Failed to load parser '@babel/eslint-parser' declared in '.eslintrc.cjs » /Users/macintosh/node_modules/@reskript/config-lint/config/eslint.cjs » /Users/macintosh/node_modules/@ecomfe/eslint-config/strict.js': Cannot find module '/Users/macintoshnode_modules/semver/index.js'. Please verify that the package.json has a valid "main" entry
    at tryPackage (internal/modules/cjs/loader.js:310:19)
    at Function.Module._findPath (internal/modules/cjs/loader.js:523:18)
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:921:27)
    at Module._load (internal/modules/cjs/loader.js:779:27)
    at Function.f._load (electron/js2c/asar_bundle.js:5:12913)
    at Module.require (internal/modules/cjs/loader.js:1006:19)
    at require (internal/modules/cjs/helpers.js:88:18)
    at Object.<anonymous> (/Users/macintosh/Desktop/workspaces/baidu/hec/iot-fe/node_modules/@babel/eslint-parser/lib/parse.cjs:3:16)
    at Module._compile (internal/modules/cjs/loader.js:1125:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1155:10)

package.json

{
  "name": "aaaa",
  "version": "1.0.0",
  "main": "./dist/index.js",
  "types": "./dist/index.d.ts",
  "engines": {
    "node": ">=14.18.0 || >= 16.0.0"
  },
otakustay commented 2 years ago

发一下.eslintrc.cjs?你应该是个干净的init出来的项目么?给一下node、npm或者你的包管理器的版本,这可能和包管理器安装的目录结构有关

believeZJP commented 2 years ago

是一个新项目

// require('@reskript/config-lint/patch');

module.exports = {
    extends: require.resolve('@reskript/config-lint/config/eslint'),
    rules: {
        'no-underscore-dangle': ['error', {'allow': ['__REDUX_DEVTOOLS_EXTENSION__']}],
        'no-console': 'off',
        'react/jsx-no-bind': ['off', {
            'allowArrowFunctions': 0,
        }],
        'object-curly-spacing': ['off'],
        'complexity': ['off'],

    },
};

$ node -v                                         
v14.18.0

$ npm -v                                          
6.14.15
{
  "name": "aaaa",
  "version": "1.0.0",
  "main": "./dist/index.js",
  "types": "./dist/index.d.ts",
  "engines": {
    "node": ">=14.18.0 || >= 16.0.0"
  },
  "license": "MIT",
  "scripts": {
    "start": "skr dev",
    "build": "skr build --clean",
    "analyze": "yarn build --analyze --build-target=stable",
    "lint": "skr lint",
    "lint-staged": "skr lint --staged --fix --auto-stage",
    "test": "skr test --target=react"
  },
  "dependencies": {
    "@ant-design/pro-card": "^1.18.32",
    "@ant-design/pro-form": "^1.53.5",
    "@ant-design/pro-table": "^2.63.5",
    "@reduxjs/toolkit": "^1.7.2",
    "antd": "^4.18.6",
    "axios": "^0.25.0",
    "clipboard": "^2.0.10",
    "core-js": "^3.21.0",
    "js-cookie": "^3.0.1",
    "moment": "^2.29.1",
    "nprogress": "^0.2.0",
    "query-string": "^7.1.1",
    "react": "^17.0.2",
    "react-document-title": "^2.0.3",
    "react-dom": "^17.0.2",
    "react-loadable": "^5.5.0",
    "react-redux": "^7.2.6",
    "react-router-dom": "^6.2.1",
    "react-transition-group": "^4.4.2",
    "redux": "^4.1.2",
    "redux-thunk": "^2.4.1",
    "styled-components": "^5.3.3"
  },
  "devDependencies": {
    "@reskript/cli": "4.1.1",
    "@reskript/cli-build": "4.1.1",
    "@reskript/cli-dev": "4.1.1",
    "@reskript/cli-lint": "4.1.1",
    "@reskript/config-lint": "4.1.1",
    "@types/react": "^17.0.39",
    "@types/react-dom": "^17.0.11",
    "eslint": "^8.8.0",
    "husky": "4.x",
    "stylelint": "^14.4.0",
    "typescript": "^4.5.5",
    "webpack": "^5.68.0"
  },
  "husky": {
    "hooks": {
      "pre-commit": "npm run lint-staged"
    }
  }
}
otakustay commented 2 years ago

我试了一下没有出现你的问题,我看到你把require('@reskript/config-lint/patch');这行注释掉了,这个的原因是?

believeZJP commented 2 years ago

我的项目重启以后也不复现了。具体注释原因我也忘了,不小心注释掉了...

otakustay commented 2 years ago

OK,那我先当这个问题已经解决,有问题随时联系

believeZJP commented 2 years ago

好的