wp-env无法找到WordPress的版本和网络信息

后端开发 2026-07-12

我在桌面上尝试运行wp-env,但每次都会遇到同样的错误:

× Could not find the current WordPress version in the cache and the network is not available.
Error: Could not find the current WordPress version in the cache and the network is not available.
    at getLatestWordPressVersion (C:\Users\truls\AppData\Roaming\npm\node_modules\@wordpress\env\lib\wordpress.js:93:10)
    at async parseCoreSource (C:\Users\truls\AppData\Roaming\npm\node_modules\@wordpress\env\lib\config\parse-config.js:628:21)
    at async parseEnvironmentConfig (C:\Users\truls\AppData\Roaming\npm\node_modules\@wordpress\env\lib\config\parse-config.js:544:4)
    at async parseRootConfig (C:\Users\truls\AppData\Roaming\npm\node_modules\@wordpress\env\lib\config\parse-config.js:375:23)
    at async getDefaultConfig (C:\Users\truls\AppData\Roaming\npm\node_modules\@wordpress\env\lib\config\parse-config.js:272:9)
    at async parseConfig (C:\Users\truls\AppData\Roaming\npm\node_modules\@wordpress\env\lib\config\parse-config.js:150:24)
    at async loadConfig (C:\Users\truls\AppData\Roaming\npm\node_modules\@wordpress\env\lib\config\load-config.js:78:15)
    at async start (C:\Users\truls\AppData\Roaming\npm\node_modules\@wordpress\env\lib\commands\start.js:55:17)
  • 我已经重新安装了所有东西(node、npm、wp、Docker)
  • 尝试了较早版本的node(目前使用的是v22.22.0)
  • 多次清理缓存和容器后重新尝试
  • 通过Docker进行ping,以确保网络可达
  • 重新安装Git

这里也给出我的.wp-env:

{
    "mappings": {
        "wp-content": "./wp-content"
    }
}

同样的设置在我的笔记本上可用。有什么办法可以解决这个问题?

解决方案

只需打开这个文件:

C:\Users\USERNAME\AppData\Roaming\npm\node_modules\@wordpress\env\lib\wordpress.js

然后把第63行改为:

IS_OFFLINE = ! ( await dns.resolve( 'WordPress.org' ).catch( () => {} ) );

这个问题在未来可能会被修复。

站内所有文章版权归属LeftHeroAI导航站,无授权禁止任何主体转载、抄袭、复制内容,亦不得私自架设镜像站点。一经侵权,本站将通过法律途径追责。

相关文章