E:\source\m-yuying-nextjs\package.json文件,现在运行yarn dev 无法启动,报错:[baseline-browser-mapping] The data in this module is over two months old. To ensure accurate Baseline data, please update: `npm i baseline-browser-mapping@latest -D` ⨯ Unable to acquire lock at E:\source\m-yuying-nextjs\.next\dev\lock, is another instance of next dev running? Suggestion: If you intended to restart next dev, terminate the other process, and then try again.
这个错误是由.next/dev/lock锁文件导致的。让我解释一下原因:
锁文件机制:Next.js 在启动开发服务器时会创建一个锁文件
.next/dev/lock,用于防止同时运行多个开发服务器实例您之前运行了多个 Node.js 进程:从
taskkill的输出可以看到,系统中有12 个 Node.js 进程正在运行:- 可能是您多次运行
yarn dev但没有正确关闭 - 或者之前的进程崩溃了但锁文件没有被清理
- 可能是您多次运行
锁文件没有被清理:当 Node.js 进程异常退出时,锁文件可能会残留在
.next/dev/目录中