错误:无法在常量-fs中解析“常量”

问题描述

我安装了一个js软件包fs-constants,该软件包使用其browser.js文件中的下一行。

module.exports = require('constants')

我在编译时收到此错误

ERROR in ./node_modules/fs-constants/browser.js
Module not found: Error: Can't resolve 'constants' in '/mnt/c/Users/jbermudez/workspace/HMI_WEB_CONVERTIDORES/front/node_modules/fs-constants'

我检查是否已安装名为constants-browserify的软件包,但似乎无法解决问题

解决方法

好吧,fs-constants模块依赖于另一个称为常量的模块,该模块现在已弃用,因为该模块本身的npm位置表示。现在使用require("fs").constants进行调用,但这仅是节点。您在哪个节点版本上?从v12.18开始,常量模块仍然存在,可以为我调用。