简体   繁体   English

未能加载 SWC 二进制文件

[英]Failed to load SWC binary

When trying to run the command using Next.js npm run dev shows error - failed to load SWC binary see more info here: https://nextjs.org/docs/messages/failed-loading-swc.尝试使用 Next.js npm run dev命令时显示error - failed to load SWC binary see more info here: https://nextjs.org/docs/messages/failed-loading-swc.

PS D:\web-development\new-project\explore> npm run dev

> dev     
> next dev

ready - started server on 0.0.0.0:3000, url: http://localhost:3000
Error: The specified module could not be found.
\\?\D:\web-development\new-project\explore\node_modules\@next\swc-win32-x64-msvc\next-swc.win32-x64-msvc.node
    at Object.Module._extensions..node (node:internal/modules/cjs/loader:1179:18)
    at Module.load (node:internal/modules/cjs/loader:975:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:999:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at loadNative (D:\web-development\new-project\explore\node_modules\next\dist\build\swc\index.js:84:28)
    at loadBindings (D:\web-development\new-project\explore\node_modules\next\dist\build\swc\index.js:41:32)
    at async Object.isWasm (D:\web-development\new-project\explore\node_modules\next\dist\build\swc\index.js:146:20)
    at async D:\web-development\new-project\explore\node_modules\next\dist\build\webpack\loaders\next-swc-loader.js:62:178 {
  code: 'ERR_DLOPEN_FAILED'
}
error - Failed to load SWC binary, see more info here: https://nextjs.org/docs/messages/failed-loading-swc
PS D:\web-development\new-project\explore>

The way I solved it.我解决它的方法。

In the beginning, I follow the doc link which was given with error.一开始,我按照错误给出的文档链接进行操作。

error - Failed to load SWC binary, see more info here: https://nextjs.org/docs/messages/failed-loading-swc错误 - 无法加载 SWC 二进制文件,请在此处查看更多信息: https://nextjs.org/docs/messages/failed-loading-swc

Go to this link https://nextjs.org/docs/messages/failed-loading-swc and read this doc. Go 到此链接https://nextjs.org/docs/messages/failed-loading-swc并阅读此文档。

Then go to this link https://swc.rs/ .然后 go 到这个链接https://swc.rs/ Download the SWC binary prebuild and add the Transpile JavaScript file.下载 SWC 二进制预编译并添加 Transpile JavaScript 文件。

# Download prebuilt binaries
npm i -D @ swc / cli @ swc / core

# Transpile JavaScript file and emit to stdout
npx swc ./file.js

Then again go to this link https://nextjs.org/docs/messages/failed-loading-swc and create the.babelrc file next to next.config.js.然后再将 go 指向此链接https://nextjs.org/docs/messages/failed-loading-swc并在 next.config.js 旁边创建.babelrc 文件。 Inserts the code from the doc inside the.babelrc file.将 doc 中的代码插入 .babelrc 文件中。

{
    "presets": ["next / babel"]
}

Then "npm run dev" will be fine.然后“npm run dev”就可以了。

If your error happen after cloning the project from git you can try my step如果从 git 克隆项目后发生错误,您可以尝试我的步骤

i have same problem with you in windows 11 when i clone the project from my old repo.当我从旧仓库克隆项目时,我在 windows 11 中遇到了同样的问题。 first i try to remove yarn.lock and node_modules, then install the dependencies again, but it doesn't work.首先我尝试删除 yarn.lock 和 node_modules,然后再次安装依赖项,但它不起作用。

after a few minute, i figure out because i have permission problem.几分钟后,我发现是因为我有权限问题。 i install git with chocolately as administrator, so, i remove the git from choco我以管理员身份安装 git,因此,我从 choco 中删除了 git

choco uninstall git

the I install git from git scm.我从 git 单片机安装 git。 you can download it here https://git-scm.com/downloads你可以在这里下载https://git-scm.com/downloads

after that I clone the project, run yarn and it's work like a charm.之后我克隆项目,运行纱线,它就像一个魅力。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Next 加载 SWC 二进制文件失败 - Next failed to load SWC binary 为什么 getStaticProps 给出“无法为 win32/x64 加载 SWC 二进制文件”的错误? - Why getStaticProps giving error of "Failed to load SWC binary for win32/x64"? Next.js 错误 - 无法加载 SWC 二进制文件,请在此处查看更多信息:https://nextjs.org/docs/messages/failed-loading-swc - Next.js error - Failed to load SWC binary, see more info here: https://nextjs.org/docs/messages/failed-loading-swc 使用绑定安装和 Yarn 3 在 Docker 中使用 SWC minify 开发 Next.js:缺少 swc-linux-x64-gnu linux 二进制文件 - Developing Next.js with SWC minify in Docker with bind mount and Yarn 3: missing swc-linux-x64-gnu linux binary 错误:下载 Cypress 二进制文件失败 - Error: Failed downloading the Cypress binary 如何在 Next JS 中启用 SWC 别名导入? - How to enable SWC Aliased imports in Next JS? 如何解决 NextJs Error: Failed to load / at loadComponents - How to solve NextJs Error: Failed to load / at loadComponents Docker 构建不适用于 node:alpine 和 SWC 上的 NextJS - Docker build not working with NextJS on node:alpine with SWC 错误:无法加载配置“下一个”以从 - Error: Failed to load config "next" to extend from 无法加载具有空路径和回退的 static 道具 - Failed to load static props with empty paths and fallback
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM