javascript - "Uncaught TypeError: undefined is not a function" vanishes after computer restarted
问题描述
I'm building a React component library using rollup
for the build and webpack-dev-server
to run a demo. While hacking away last night, using the demo to see my changes, I was running into an Uncaught TypeError: undefined is not a function
that would simply not go away as long as a certain line was included in my code.
The line of code was defaultCheckboxRender(CheckboxComponent, label);
but please just assume that sufficient debugging was done to determine that none of those identifiers were undefined and that all were within the proper scope. After slamming my head on this for several hours, I shut down my Windows 10 computer to install some updates and went to bed. This morning, I boot up my project, run the demo to continue this nightmare and, lo and behold, the error is gone. I did not change the code since I last encountered the error but for some reason, it's not happening anymore.
Now... I set up the webpack config myself and it was the first time I have done such a thing. My best guess is that this problem is related to how the files are served and compiled and such. Here is the webpack.config.js
file https://gist.github.com/dumptruckman/db7001568077497fe1aaa0b4db9d8424. One thing to note is that when I run my demo, I do not see a dist folder appear in my project directory which struck me as kind of odd but I'm not sure why it's like that.
Has anyone experienced anything like this before and how do I prevent it from happening in the future?
解决方案
通过将 HotModuleReplacementPlugin 添加到我的 webpack 配置中解决了这个问题。更新的配置可以在这里看到:https ://gist.github.com/dumptruckman/7de7ff7e9526bff4408f0cea6fb4bbe5
推荐阅读
- svn - 我可以从哪里下载旧的 VSTS 代理?
- rest - Web API 控制器中的基类和派生类
- python - QueryDict 在 Django 中返回奇怪的值
- python - 为什么 [] 和 [[]] 在 numpy 操作中有所不同
- mongodb - Mongodb - 来自两个集合的多个字段的内连接
- java - 从火花流到谷歌大查询是否有任何连接器?
- jquery - 如何选择 preventDefault() 并将其放入与特定类的链接
- android - 底片膨胀需要多长时间
- java - IllegalStateException 无法为 unitName null 检索 EntityManagerFactory
- google-cloud-platform - JSON_EXTRACT_SCALAR 解析后返回 null