简体   繁体   English

如何解决我的npm包的“关键依赖关系:依赖关系的请求是一个表达式”错误?

[英]How to resolve “Critical dependency: the request of a dependency is an expression” error for my npm package?

I have a package called all-keyboardevent-keys that exports an object of keyboardevent strings. 我有一个名为all-keyboardevent-keys的程序包,该程序包可导出keyboardevent字符串对象。 This package is a dependency in another package that I created, onkey-event-manager , which I have included in a Gatsby site. 该软件包是我创建的另一个软件包onkey-event-manager的依赖项,该软件包已包含在Gatsby站点中。

Whenever I start the Gatsby development server on my site, I get the following warning: 每当我在自己的站点上启动Gatsby开发服务器时,都会收到以下警告:

WARNING  Compiled with 1 warnings

warning  in ./node_modules/all-keyboardevent-keys/lib/index.js

Critical dependency: the request of a dependency is an expression

In searching around, I have learned that this warning comes from webpack , a library that I know little about. 在四处搜寻时,我了解到此警告来自webpack ,这是我鲜为人知的库。

I would love to resolve this warning in my package so other users don't have a problem. 我很乐意解决我的包装中的此警告,以便其他用户没有问题。 Unfortunately, most of the answers on this site and others are for end users and not package maintainers. 不幸的是,此站点上的大多数答案以及其他答案都是针对最终用户的,而不是针对软件包维护者的。

What can I do, as a package author, to resolve this warning? 作为软件包作者,我该怎么做才能解决此警告?

The dependency package in question, all-keyboard-events , had not been built correctly. 有问题的依赖程序包all-keyboard-events尚未正确构建。 I replaced Parcel with Babel, updated the build configurations, built again, and the error was resolved. 我用Babel替换了Parcel,更新了构建配置,再次构建,错误得以解决。

I thought this was an instance of Webpack being too particular; 我认为这是Webpack过于具体的一个例子。 instead it was catching an error that my tests cases had missed. 相反,它捕获了我的测试用例遗漏的错误。

Hopefully that is helpful for anyone else experiencing the same issue. 希望对其他遇到相同问题的人有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何解决 npm 依赖 - How to resolve npm dependency 关键依赖:一个依赖的请求是一个表达式——react-universal-component - Critical dependency: the request of a dependency is an expression -- react-universal-component 关键依赖项:依赖项的请求是jQuery Form Validator插件上的一个表达式 - Critical dependency: the request of a dependency is an expression on jQuery Form Validator plugin Webpack编译不正确(严重依赖性:依赖性的请求是一个表达式) - Webpack not properly compiling (Critical dependency: the request of a dependency is an expression) 关键依赖:依赖的请求是使用延迟加载时的表达式 - Critical dependency: the request of a dependency is an expression while using lazy loading 关键依赖:依赖的请求是一个表达式(Angular CLI 警告) - Critical dependency: the request of a dependency is an expression (Angular CLI Warning) ./node_modules/express/lib/view.js 中的 Webpack 警告关键依赖:依赖的请求是一个表达式 - Webpack WARNING in ./node_modules/express/lib/view.js Critical dependency: the request of a dependency is an expression 覆盖 npm 包依赖 - Override npm package dependency Webpack Express无法解析模块“ fs”,请求依赖关系为表达式 - Webpack Express Cannot Resolve Module 'fs', Request Dependency is Expression 向 npm 包添加自制程序依赖项 - Adding a homebrew dependency to an npm package
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM