当前位置: 首页 > 工具软件 > lint-md > 使用案例 >

Cannot find module lint-staged 解决办法

汪才
2023-12-01

使用git lint-stag后,再commit时报错 Cannot find module lint-staged

internal/modules/cjs/loader.js:818
  throw err;
  ^

Error: Cannot find module 'C:\Users\yunlu\Desktop\yuntuan\yuntuanwebsite\node_modules\lint-staged\index.js'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:815:15)
    at Function.Module._load (internal/modules/cjs/loader.js:667:27)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12)
    at internal/main/run_main_module.js:17:47 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}
husky - pre-commit hook exited with code 1 (error)

重新npm install和npm install lint-stag都不生效,最后把node_modules删掉,再重新npm install就好用啦!

PS C:\Users\yunlu\Desktop\xxx> npm install
npm WARN old lockfile
npm WARN old lockfile The package-lock.json file was created with an old version of npm,
npm WARN old lockfile so supplemental metadata must be fetched from the registry.
npm WARN old lockfile
npm WARN old lockfile This is a one-time fix-up, please be patient...
npm WARN old lockfile
npm WARN deprecated source-map-url@0.4.1: See https://github.com/lydell/source-map-url#deprecated
npm WARN deprecated urix@0.1.0: Please see https://github.com/lydell/urix#deprecated
npm WARN deprecated source-map-resolve@0.5.3: See https://github.com/lydell/source-map-resolve#deprecated
npm WARN deprecated resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated
> yuntuan-react@0.1.0 prepare
> husky install

husky - Git hooks installed

added 427 packages, removed 42 packages, and changed 290 packages in 2m
PS C:xxx> git commit -m "fix: 更改ws 服务端接口"

> yuntuan-react@0.1.0 lint
> eslint src --fix --ext .ts,.tsx,.vue,.js,.jsx


> yuntuan-react@0.1.0 lint-staged
> lint-staged

Stashing changes... [started]
Stashing changes... [skipped]
→ No partially staged files found...
Running linters... [started]
Running tasks for src/**/*.{js,jsx,vue,ts,tsx} [started]
eslint --ext .js,.jsx,.vue,.ts,.tsx src --fix [started]
eslint --ext .js,.jsx,.vue,.ts,.tsx src --fix [completed]
eslint --fix --max-warnings 0 [started]
eslint --fix --max-warnings 0 [completed]
prettier --write [started]
prettier --write [completed]
git add [started]
git add [completed]
Running tasks for src/**/*.{js,jsx,vue,ts,tsx} [completed]
Running linters... [completed]
[dev db5742da5] fix: 更改ws 服务端接口
 1 file changed, 24 insertions(+), 26 deletions(-)
PS C:\Users\yunlu\Desktop\xxx> git pull
remote: Enumerating objects: 5, done.
remote: Counting objects: 100% (5/5), done.
remote: Compressing objects: 100% (5/5), done.
remote: Total 5 (delta 0), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (5/5), 3.09 KiB | 4.00 KiB/s, done.
From http://192.168.xx.xxx:xxxx/xxx/yuntuanwebsite
   9cfe3c929..002f1a494  dev                   -> origin/dev
   002f1a494..4839e541b  feature_login_xxx -> origin/feature_login_xxx
Merge made by the 'ort' strategy.
 README.md                                          |   9 +-
 src/components/Navigations/Navigation/index.scss   |   1 -
 .../Navigations/PersonalCenter/index.jsx           |   8 --
 src/components/Navigations/index.jsx               |  12 +-
 src/components/RightPopup/index.jsx                | 132 +++++++++++++--------
 src/components/RightPopup/index.scss               |   3 -
 src/components/x6_reademe.md                       |   1 -
 src/config/index.js                                |  20 +---
 src/index.css                                      |  19 +--
 9 files changed, 90 insertions(+), 115 deletions(-)
 类似资料: