Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
463 views
in Technique[技术] by (71.8m points)

javascript - vertx module not found when using webpack

When using webpack and libraries that want to use when.js (when), it is possible that the following error is thrown when compiling:

[2] ERROR in ./node_modules/when/lib/env.js 32:14-35
[2] Module not found: Error: Can't resolve 'vertx' in 'path-to-project/node_modules/when/lib'

The issue seems to be isolated to webpack, and is documented on when's github. Running npm install vertx or npm install @vertx/core will not resolve the issue either, since the problem lays in the import of vertx in the when library.

question from:https://stackoverflow.com/questions/65649359/vertx-module-not-found-when-using-webpack

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

To resolve the issue:

Install @vertx/core (npm i @vertx/core)

Edit the file ./node_modules/when/lib/env.js, and change line 32 from

var vertx = vertxRequire('vertx');

to

var vertx = vertxRequire('@vertx/core');

This will reference the @vertx/core package instead of the vertx package, which does not seem to be able to be found when using webpack and npm. I haven't experienced any issues with just using vertx/core. You might also need to update your gitignore to include the changes to the library if others are also working on your project.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...