我正在尝试使用编译应用程序与闭包编译器教程在Windows 7上构建openlayers-3的自定义应用程序。当运行close -util构建选项时,我得到以下结果:
C:Roywebsitesphp_js_projectsclosure-compiler>node_modulesopenlayersnode_mo
dules.binclosure-util build config.json app.js
info closure-util Reading build config
info closure-util Getting Closure dependencies
info closure-util Compiling 367 sources
child_process.js:1162
throw errnoException(err, 'spawn');
^
Error: spawn ENAMETOOLONG
at exports._errnoException (util.js:746:11)
at ChildProcess.spawn (child_process.js:1162:11)
at Object.exports.spawn (child_process.js:995:9)
at Object.module.exports [as compile] (C:Roywebsitesphp_js_projectsclosu
re-compilernode_modulesopenlayersnode_modulesclosure-utillibcompile.js:42:
18)
at compile (C:Roywebsitesphp_js_projectsclosure-compilernode_modulesop
enlayersnode_modulesclosure-utillibbuild.js:94:11)
at fn (C:Roywebsitesphp_js_projectsclosure-compilernode_modulesopenlay
ersnode_modulesclosure-utilnode_modulesasynclibasync.js:579:34)
at Immediate._onImmediate (C:Roywebsitesphp_js_projectsclosure-compiler
node_modulesopenlayersnode_modulesclosure-utilnode_modulesasynclibasync.j
s:495:34)
at processImmediate [as _immediateCallback] (timers.js:358:17)
我没有发现谷歌网络搜索或搜索在这里讨论这个问题。有解决办法吗?
我今天遇到了这个问题,并找到了一个解决方法。我认为问题在于OpenLayers 3提供了一个过时的闭包版本-直到其package.json
中指定。在OpenLayers开发者自己指定新版本之前,我发现切换到最新版本的closure-util解决了这个问题。
处理:
在OpenLayers目录下执行以下所有操作(在您的情况下似乎是C:Roywebsitesphp_js_projectsclosure-compilernode_modulesopenlayers
)。为了保持一致性,我让下面的示例参考您的路径:
-
打开
package.json
,寻找"dependencies"
部分并将close -util的版本从1.5.0更改为更新版本(撰写本文时最新版本为1.7.0)。"dependencies": { .. "closure-util": "1.5.0", .. },
是
"dependencies": { .. "closure-util": "1.7.0", .. },
-
通过从
node_modules
目录中删除整个closure-util
目录来删除旧版本的close -util。(删除C:Roywebsitesphp_js_projectsclosure-compilernode_modulesopenlayersnode_modulesclosure-util
) -
在
openlayers
目录下运行npm install
。这将使节点包管理器自动检索最新版本的closure-util,以替换我们在上一步中删除的版本。C:Roywebsitesphp_js_projectsclosure-compilernode_modulesopenlayers>npm install - > ws@0.4.32 install C:Roywebsitesphp_js_projectsclosure-compilernode_modulesopenlayersnode_modulesclosure-utilnode_modulessocket.ionode_modulessocket.io-clientnode_modulesws ..snip.. > closure-util@1.7.0 postinstall C:Roywebsitesphp_js_projectsclosure-compilernode_modulesopenlayersnode_modulesclosure-util > node ./bin/closure-util.js update info install Downloading http://dl.google.com/closure-compiler/compiler-20150729.zip ..snip..
-
请重新构建。
C:Roywebsitesphp_js_projectsclosure-compiler>node_modulesopenlayersnode_modules.binclosure-util build config.json app.js