[英]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”就可以了。
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.