错误 发生意外错误:“需要提交哈希”

Dol*_*hin 5 javascript vue.js

当我使用此命令添加 eslint( @vue/cli 4.5.15) 时:

vue add eslint
Run Code Online (Sandbox Code Playgroud)

显示这样的错误:

 WARN  There are uncommitted changes in the current repository, it's recommended to commit or stash them first.
? Still proceed? Yes

  Installing @vue/cli-plugin-eslint...

yarn add v1.22.17
[1/4]   Resolving packages...
[2/4]   Fetching packages...
info If you think this is a bug, please open a bug report with the information provided in "/Users/xiaoqiangjiang/source/reddwarf/frontend/crx-selection-translate/yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.
error An unexpected error occurred: "Commit hash required".
 ERROR  command failed: yarn add @vue/cli-plugin-eslint@~4.5.0 -D
Run Code Online (Sandbox Code Playgroud)

我应该怎么做才能解决这个问题?我已经尝试删除锁定文件,但仍然没有解决这个问题。节点版本是v16.13.2.

M1R*_*der 20

npm install当您在纱线项目上使用 a 时,通常会发生这种情况,然后yarn install您意识到 npm 不起作用。不知何故yarn.lock被损坏。这是我所做的:

rm package-lock.json
rm yarn.lock
git checkout <old-hash> yarn.lock
Run Code Online (Sandbox Code Playgroud)


Saj*_*han 5

对我来说,我做了以下工作并且有效:

$ rm package-lock.json    # remove the package-lock.json file

$ yarn install  # install successfully and update the yarn.lock file
Run Code Online (Sandbox Code Playgroud)