使用js-enumerate报错Cannot set properties of undefined

环境

  • node v16.20.2
  • react 18.3.1
  • react-scripts 5.0.1

按照最新 npx create-react-app my-app 创建出来的新项目,引入 js-enumerate 库后运行报错。

报错

  Uncaught runtime errors:

ERROR
Cannot set properties of undefined (setting 'Enum')
TypeError: Cannot set properties of undefined (setting 'Enum')
    at http://localhost:3000/static/js/bundle.js:106620:201
    at ./node_modules/js-enumerate/dist/index.js (http://localhost:3000/static/js/bundle.js:106621:2)
    at options.factory (http://localhost:3000/static/js/bundle.js:108518:31)
    at __webpack_require__ (http://localhost:3000/static/js/bundle.js:107925:32)
    at fn (http://localhost:3000/static/js/bundle.js:108177:21)
    at ./src/index.js (http://localhost:3000/static/js/bundle.js:556:70)
    at options.factory (http://localhost:3000/static/js/bundle.js:108518:31)
    at __webpack_require__ (http://localhost:3000/static/js/bundle.js:107925:32)
    at http://localhost:3000/static/js/bundle.js:109097:37
    at http://localhost:3000/static/js/bundle.js:109099:12

解决方法

react-scripts5.0.1 降级到 4.0.3 ,项目正常运行。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值