Openlayers 3 Openlayers自定义构建教程正在崩溃

Openlayers 3 Openlayers自定义构建教程正在崩溃,openlayers-3,Openlayers 3,我正在通过,我得到以下错误 info ol Parsing dependencies info ol Compiling 345 sources events.js:141 throw er; // Unhandled 'error' event ^ Error: spawn java ENOENT at exports._errnoException (util.js:870:11) at Process.ChildProcess._handle.onexit (

我正在通过,我得到以下错误

info ol Parsing dependencies
info ol Compiling 345 sources
events.js:141
  throw er; // Unhandled 'error' event
  ^

Error: spawn java ENOENT
   at exports._errnoException (util.js:870:11)
   at Process.ChildProcess._handle.onexit 
   (internal/child_process.js:178:32)
   at onErrorNT (internal/child_process.js:344:16)
   at nextTickCallbackWith2Args (node.js:441:9)
   at process._tickCallback (node.js:355:17)
Exit 1
当我跑步时:

 node tasks/build.js build/ol-custom.json build/ol-custom.js
 node tasks/build.js build/ol-custom.json build/ol-custom.js
通过谷歌搜索错误,可以找到一个解决方案,其中可能是另一个在后台运行的节点实例(没有)

本教程还指出,closure util应该位于:

node_modules/openlayers/node_modules
但实际上是:

node_modules/closure-util

知道为什么会发生这种情况吗?

结果是java没有在我的路径上正确设置,因此无法构建。记住用java版本检查您的环境

在Ubuntu上,您可以安装java 11(使用此版本):

它应返回:

openjdk version "11.0.8" 2020-07-14
OpenJDK Runtime Environment (build 11.0.8+10-post-Ubuntu-0ubuntu118.04.1)
OpenJDK 64-Bit Server VM (build 11.0.8+10-post-Ubuntu-0ubuntu118.04.1, mixed mode, sharing)
然后您可以再次运行:

 node tasks/build.js build/ol-custom.json build/ol-custom.js