简体   繁体   English

为什么 getStaticProps 给出“无法为 win32/x64 加载 SWC 二进制文件”的错误?

[英]Why getStaticProps giving error of "Failed to load SWC binary for win32/x64"?

I am using getStaticProps() in a Next.js app but when I run the app it gives ERROR:-我在 Next.js 应用程序中使用 getStaticProps() 但是当我运行该应用程序时它给出了错误:-

warn  - Attempted to load @next/swc-win32-x64-gnu, but it was not installed
warn  - Attempted to load @next/swc-win32-x64-msvc, but an error occurred: The specified 
module could not be found.
\\?\D:\tasks\next-js\node_modules\@next\swc-win32-x64-msvc\next-swc.win32-x64-msvc.node
error - Failed to load SWC binary for win32/x64, see more info here: 
https://nextjs.org/docs/messages/failed-loading-swc
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! next-js@0.1.0 dev: `next dev`
npm ERR! Exit status 1
npm ERR!

I tried all methods like uninstalling node_module, package-lock and reinstalling it.我尝试了所有方法,例如卸载 node_module、package-lock 并重新安装它。 I tried adding .babelrc file, also added swcMinify: false in next.config but nothing works.我尝试添加 .babelrc 文件,还在 next.config 中添加了 swcMinify: false 但没有任何效果。
When I use useEffect instead of getStaticProps then it works fine.当我使用 useEffect 而不是 getStaticProps 时,它可以正常工作。 Here is the getStaticProps function:-这是 getStaticProps 函数:-

export const getStaticProps = async () =>{

const res = await fetch('https://jsonplaceholder.typicode.com/posts');
const data = await res.json();

return{
    props: {
        data,
    }
  };
};

This issue appears when running next@12.1.6 and happens even if your .babelrc file and next.config.js files are configured to not load swc.运行next@12.1.6时会出现此问题,即使您的.babelrc文件和next.config.js文件配置为不加载 swc 也会发生。

If you downgrade to next@12.1.0 , the swc binary load error should go away.如果您降级到next@12.1.0 ,则 swc 二进制加载错误应该会消失。

暂无
暂无

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

相关问题 为 Win32 x64 编译后,Electron 应用程序无法打开 - Electron app won't open after compiling for Win32 x64 如何修复 fsevents@2.1.3 不支持的平台:想要 {“os”:“darwin”,“arch”:“any”}(当前:{“os”:“win32”,“arch”:“x64”} ) - how to fix Unsupported platform for fsevents@2.1.3: wanted {“os”:“darwin”,“arch”:“any”} (current: {“os”:“win32”,“arch”:“x64”}) Javascript window.open在Win7 x64上的32位IE8中返回null - Javascript window.open returns null in 32-bit IE8 on Win7 x64 为什么window.navigator.platform 在64 位机器上返回WIN32? - Why does window.navigator.platform return WIN32 on a 64-bit machine? 在ie11中损坏的HTML5本地存储赢了8.1 x64? 错误:预期功能 - HTML5 local storage broken in ie11 win 8.1 x64 ? error: function expected jQuery“ find()”在Internet Explorer 10中导致Win32错误,但在9中却没有 - jQuery “find()” causing a win32 error in Internet Explorer 10, but not 9 错误:bcrypt_lib.node 不是有效的 Win32 应用程序 - Error: bcrypt_lib.node is not a valid Win32 application window.open(“ \\\\\\\\ localhost \\\\”); 不适用于win7(x64)ie8 - window.open(“\\\\localhost\\”); not working on win7(x64) ie8 包裹错误 - 找不到模块@parcel\\fs-search\\fs-search.win32-x64-msvc.node - Parcel Error - module not found @parcel\fs-search\fs-search.win32-x64-msvc.node 动态符号检索错误:Win32错误127 - 即使在导入自我进程时也是如此 - Dynamic Symbol Retrieval Error: Win32 error 127 - even when importing self process
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM