[eggjs/egg]fs-extra 模块不能正常使用

2025-10-27 839 views
7
What happens?

https://github.com/jprichardson/node-fs-extra 这个模块在egg里用不了,

How To Reproduce

Steps to reproduce the behavior:

  1. image 一旦添加红框中的代码,运行dev,直接报错 image

  2. 去掉红框里的代码,运行dev,就ok正常。

  3. package.json { "private": true, "version": "1.5.1", "description": "Preview glTF models using three.js and a drag-and-drop interface.", "author": "Don McCurdy <dm@donmccurdy.com> (https://www.donmccurdy.com)", "license": "MIT", "main": "public/app.js", "proxy": "http://127.0.0.1:801", "targets": { "main": { "engines": { "browsers": [ "> 1%", "not dead" ] } } }, "staticFiles": { "staticPath": [ { "staticPath": "assets", "staticOutDir": "assets" } ] }, "scripts": { "build": "parcel public index.html --public-url . --out-dir public", "build:registry": "curl https://rawgit.com/KhronosGroup/glTF-Generator-Registry/master/registry.json -o lib/gltf-generator-registry.json", "dev": "parcel index.html --port 3000", "test": "node scripts/gen_test.js", "deploy": "npm run build && vercel --local-config vercel.json --prod", "postversion": "git push && git push --tags" }, "dependencies": { "axios": "^0.21.1", "can": "^6.6.1", "dat.gui": "^0.7.7", "glob-to-regexp": "^0.4.1", "glsl-blend-soft-light": "^1.0.5", "glsl-film-grain": "^1.0.4", "gltf-validator": "^2.0.0-dev.3.3", "handlebars": "^4.7.6", "jquery": "^3.6.0", "query-string": "^7.0.0", "simple-dropzone": "^0.8.1", "three": "^0.129.0" }, "devDependencies": { "glslify-bundle": "^5.1.1", "glslify-deps": "^1.3.2", "node-fetch": "^2.6.1", "parcel-bundler": "^1.12.4", "parcel-plugin-static-files-copy": "^2.5.0" } }

Expected behavior 1. 2.

Context
  • Node Version: v14.15.0
  • Egg Version: ^2.15.1
  • Plugin Name: node-fs-extra
  • Plugin Version: ^10.0.0
  • Platform: win10

回答

9

跟 egg 没什么关系,报错堆栈都打印出来了,自己断点查查

3

跟 egg 没什么关系,报错堆栈都打印出来了,自己断点查查

我业务代码其他都没问题,除了引用下这个库;这个库7.9kstar,我新建一个基础的nodejs项目用的话,也没啥问题;

1

请提供一个最小可复现代码库,提供后可以 reopen 本 issue

5

Hello @pxim. Please provide a reproducible example following the instruction.

Issues labeled by Need Reproduce will be closed if no activities in 7 days.


@pxim,请根据这个说明提供最小可复现代码。

如果在 7 天内没有进展会被自动关闭。

7

按这个来,提交到 GitHub 个人仓库

6

复现方式?

1

复现方式?

  1. npm install
  2. npm run dev
  3. 控制台出错
3

试了,是正常的。

看到你的依赖有 pkg 打包的,怀疑跟它有关,你可以试着 rm 掉 node_modules 后再试试。

9

试了,是正常的。

看到你的依赖有 pkg 打包的,怀疑跟它有关,你可以试着 rm 掉 node_modules 后再试试。

我用egg-examples里的案例测试是正常的,但是在我项目环境里出错;

我 删掉 node_modules ,然后又重新安装了,还是不行;算了,我不用这个库了;

9

提供不了稳定复现方式,我们也没法解决。

从原理上来想都不可能跟 egg 有关,而且错误堆栈都出来了,其实你断点下几分钟就能知道问题了。

我猜测大概率跟 pkg 构建的产物干扰有关。

9

提供不了稳定复现方式,我们也没法解决。

从原理上来想都不可能跟 egg 有关,而且错误堆栈都出来了,其实你断点下几分钟就能知道问题了。

我猜测大概率跟 pkg 构建的产物干扰有关。

我用egg init新建了一个工程,然后把pkg的配置原样拷过去,业务代码拷过去,fs-extra 可以正常使用了,其他功能也都正常;

至于为什么以前的不能用,就不清楚了