找不到模块“fs/promises"Electron JS

Cannot find module #39;fs/promises#39; Electron JS(找不到模块“fs/promisesElectron JS)
本文介绍了找不到模块“fs/promises"Electron JS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

早上好,

我在 Vue JS 中创建了一个程序,它与我在 main.js 文件中创建的 API 连接以执行系统命令.

I have created a program in Vue JS, this connects with an API that I have created in a main.js file to execute system commands.

我遇到的问题是,使用电子进行生产编译时出现以下错误:

The problem I have is that when compiling for production with electron I get the following error:

我使用命令 npm run electron: build

I use the command npm run electron: build

当我使用 npm run electron:serve work 时没有问题

When I use npm run electron:serve work without problems

有人知道为什么会出现错误以及如何解决吗?谢谢

Anyone have any idea why is the error and how to fix it? Thanks

推荐答案

我前几天也遇到过这个问题.我意识到试图解决另一个问题,我删除了 node_modules 文件夹和 package-lock.json 文件,然后运行 npm install 命令.这使得构建因fs/promises"而失败.这个问题有两种解决方案:

I experienced this issue a few days ago as well. I realized that trying to fix another issue, I deleted the node_modules folder and the package-lock.json file, then run the npm install command. This made the build to fail with 'fs/promises'. There are 2 solutions to this issue:

  1. 下载最新的稳定 Node 版本.这应该有 'fs/promises' 模块并将解决问题.
  2. 删除 node_modules 文件夹并恢复旧的 package-lock.json 文件,以确保包版本保持不变.然后运行 npm install 命令,问题应该就解决了.
  1. Download the latest stable Node version. This should have the 'fs/promises' module and will fix the issue.
  2. Delete the node_modules folder and bring back the old package-lock.json file to ensure that the package versions remain the same. Then run the npm install command and the issue should be fixed.

这篇关于找不到模块“fs/promises"Electron JS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

相关文档推荐

Node.js spawn with colors?(Node.js 产生颜色?)
Unbinding events in Node.js(Node.js 中的解除绑定事件)
Node.js: Configuration and routes in a different file(Node.js:不同文件中的配置和路由)
merge two arrays (keys and values) into an object(将两个数组(键和值)合并为一个对象)
Use quot;coffeequot; instead of quot;nodequot; command in production(使用“咖啡而不是“节点生产中的命令)
require()#39;ing a CoffeeScript file from a JavaScript file or REPL(从 JavaScript 文件或 REPL 中 require()ing CoffeeScript 文件)