简体   繁体   English

对于 next.js,为什么我突然开始看到找不到模块:错误:无法解析“fs”?

[英]With next.js, why did I suddenly start seeing Module not found: Error: Can't resolve 'fs'?

I changed nothing, but am using "next": "9.4.4" , and I see:我什么也没改变,但我正在使用"next": "9.4.4" ,我看到:

Module not found: Can't resolve 'fs' in 'web/node_modules/graceful-fs'
Could not find files for /app/d/[id] in .next/build-manifest.json
ModuleNotFoundError: Module not found: Error: Can't resolve 'fs' in 'web/node_modules/graceful-fs'

What could I be doing wrong?我做错了什么?

Looks like you're not in an /api directory.看起来您不在/api目录中。 The client side code won't be able to import fs , only the API files will客户端代码将无法导入fs ,只有 API 文件将

npm WARN deprecated urix@0.1.0: Please see https://github.com/lydell/urix#deprecated
npm WARN deprecated chokidar@2.1.8: Chokidar 2 will break on node v14+. Upgrade to chokidar 3 with 15x less dependencies.
npm WARN deprecated resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated
npm WARN deprecated fsevents@1.2.13: fsevents 1 will break on node v14+ and could be using insecure binaries. Upgrade to fsevents 2.

It looks like the issue for me is that I'm running Node 14.7.0.对我来说,问题似乎是我正在运行 Node 14.7.0。 The warnings that I get when I build the following NextJS client suggest that is the issue.我在构建以下 NextJS 客户端时收到的警告表明这是问题所在。

{
      "name": "client",
      "version": "1.0.0",
      "description": "Serverside rendered React client with NestJS",
      "main": "index.js",
      "scripts": {
        "dev": "next"
      },
      "keywords": [],
      "author": "Will Nielsen",
      "license": "ISC",
      "dependencies": {
        "@nielsendigital/ms-common": "^1.1.17",
        "axios": "^0.20.0",
        "bootstrap": "^4.5.2",
        "next": "^10.0.2",
        "react": "^17.0.1",
        "react-dom": "^17.0.1",
        "react-stripe-checkout": "^2.6.3"
      }
    }

I am unclear how to upgrade fsevents to v2 within NextJS.我不清楚如何在 NextJS 中将 fsevents 升级到 v2。

Your component might be rendering on the client-side.您的组件可能在客户端呈现。 Check that places you assume are rendered on the server ( getStaticProps / getServerSideProps ) might be hydrating your component and trying to run code you think should run on the server actually on the client.检查您假设在服务器上呈现的位置( getStaticProps / getServerSideProps )是否可能正在滋润您的组件并尝试运行您认为应该在服务器上实际运行在客户端上的代码。

暂无
暂无

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

相关问题 找不到模块:无法解析 Next.js 应用程序中的“fs” - Module not found: Can't resolve 'fs' in Next.js application Next.js - 使用 BigQuery 客户端库时出现错误:找不到模块:无法解析“child_process” - Next.js - using BigQuery client library gives an error : Module not found: Can't resolve 'child_process' 未找到模块:无法在 Next.js 应用程序中解析“@react-stately/collections” - Module not found: Can't resolve '@react-stately/collections' in Next.js app 未找到模块:错误:无法解析“加密”和无法解析“fs” - Module not found: Error: Can't resolve 'crypto' and Cant resolve 'fs' 如何解决 nuxt.js 中的“找不到模块:错误:无法解析‘fs’”? - How to resolve the "Module not found: Error: Can't resolve 'fs'" in nuxt.js? 找不到模块:错误:无法解析“D:\GitHub\project”中的“./C:/Users/user/AppData/Roaming/npm/node_modules/next/dist/client/next.js” - Module not found: Error: Can't resolve './C:/Users/user/AppData/Roaming/npm/node_modules/next/dist/client/next.js' in 'D:\GitHub\project' 如何解决使用react和next.js时找不到fs模块的错误 - how to solve the error that fs module is not found when used react and next.js 找不到模块:错误:无法使用 webpack 解析“fs” - Module not found: Error: Can't resolve 'fs' with webpack Webpack-NodeJS-找不到模块:错误:无法解析“ fs” - Webpack - NodeJS - Module not found: Error: Can't resolve 'fs' 找不到模块:错误:无法使用 Webpack 解析“fs” - Module not found: Error: Can't resolve 'fs' Using Webpack
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM