Openlayers 3 用闭包编译器编译应用程序
我正在尝试在Windows 7上使用带有闭包编译器的编译应用程序构建openlayers-3的自定义应用程序。在运行closure util build选项时,我得到以下结果:Openlayers 3 用闭包编译器编译应用程序,openlayers-3,custom-application,Openlayers 3,Custom Application,我正在尝试在Windows 7上使用带有闭包编译器的编译应用程序构建openlayers-3的自定义应用程序。在运行closure util build选项时,我得到以下结果: C:\Roy\websites\php\u js\u projects\closure compiler>node\u modules\openlayers\node\u mo dules\.bin\closure util build config.json app.js info closure util读取构建配
C:\Roy\websites\php\u js\u projects\closure compiler>node\u modules\openlayers\node\u mo
dules\.bin\closure util build config.json app.js
info closure util读取构建配置
info closure util获取闭包依赖项
信息:367个源代码
child_process.js:1162
抛出errnoException(err,'spawn');
^
错误:生成Enametolong
导出时出现异常(util.js:746:11)
在ChildProcess.spawn(child_process.js:1162:11)
在Object.exports.spawn(child_process.js:995:9)
在Object.module.exports[作为编译](C:\Roy\websites\php\u js\u projects\closu
重新编译\node\u modules\openlayers\node\u modules\closure util\lib\compile.js:42:
18)
编译时(C:\Roy\websites\php\u js\u projects\closure compiler\node\u modules\op
enlayers\node\u modules\closure util\lib\build.js:94:11)
在fn(C:\Roy\websites\php\u js\u projects\closure compiler\node\u modules\openlay
ers\node\u modules\closure util\node\u modules\async\lib\async.js:579:34)
立即。立即(C:\Roy\websites\php\u js\u projects\closure)\
node\u modules\openlayers\node\u modules\closure util\node\u modules\async\lib\async.j
(s:495:34)
在processImmediate[as _immediateCallback](timers.js:358:17)
我今天遇到了这个问题,并找到了解决方法。我认为问题在于OpenLayers 3附带了在其包.json
中指定的closure util的过时版本。在OpenLayers开发人员自己指定新版本之前,我发现将closure util切换到最新版本解决了这个问题
解决方法: 在OpenLayers目录下执行以下所有(在您的示例中,似乎是
C:\Roy\websites\php\u js\u projects\closure compiler\node\u modules\OpenLayers
)。为了保持一致性,我已将以下示例用于您的路径:
package.json
,查找“依赖项”
部分,将closure-util的版本从1.5.0更改为较新版本(撰写本文时最新版本为1.7.0)
变成
"dependencies": {
..
"closure-util": "1.7.0",
..
},
node\u modules
目录中删除整个closure util
目录,删除closure util的旧版本。(在本例中,删除C:\Roy\websites\php\u js\u projects\closure compiler\node\u modules\openlayers\node\u modules\closure util
)openlayers
目录中运行npm install
。这将使节点包管理器自动检索closure util的最新版本,以替换我们在上一步中删除的版本
C:\Roy\websites\php_js_projects\closure-compiler\node_modules\openlayers>npm install
-
> ws@0.4.32 install C:\Roy\websites\php_js_projects\closure-compiler\node_modules\openlayers\node_modules\closure-util\node_modules\socket.io\node_modules\socket.io-client\node_modules\ws
..snip..
> closure-util@1.7.0 postinstall C:\Roy\websites\php_js_projects\closure-compiler\node_modules\openlayers\node_modules\closure-util
> node ./bin/closure-util.js update
info install Downloading http://dl.google.com/closure-compiler/compiler-20150729.zip
..snip..
C:\Roy\websites\php_js_projects\closure-compiler>node_modules\openlayers\node_modules\.bin\closure-util build config.json app.js
C:\Roy\websites\php_js_projects\closure-compiler>node_modules\openlayers\node_modules\.bin\closure-util build config.json app.js