在babel编译之后,MomentJS return global是未定义的

MomentJS return global is undefined after babel compile

本文关键字:global 未定义 return MomentJS babel 编译 之后      更新时间:2023-09-26

我使用fullCalendar插件与MomentJS和babel编译后,我有这个关于MomentJS的错误:

global is undefined

你知道问题可能出在哪里吗?

我相信我已经找到解决这个问题的方法了。我在不同的库上得到一个错误,而不是时刻。日志报告

Module not found: Error: Cannot resolve Module 'json-loader' in/app/node_modules/sentiment/lib

然而,在babel编译(通过webpack)之后,我在控制台

中得到了相同的错误

Uncaught ReferenceError: global is not defined

当我美化压缩代码时,在

这一行抛出错误

x = global.Object。原型

我查到了图书馆的记录。Webpack使用lodash来运行babel。根据这个对话线程中的信息,通过将lodash版本从3.5.0更新到4.13.1解决了这个问题。

控制台错误和模块未找到错误都消失了。