【问题标题】:Compiling Application with Closure Compiler使用闭包编译器编译应用程序
【发布时间】:2015-05-25 15:35:29
【问题描述】:

我正在尝试使用 Compiling Application with Closure Compiler tutorial 在 Windows 7 上构建 openlayers-3 的自定义应用程序。运行closure-util 构建选项时,我得到以下信息:

C:\Roy\websites\php_js_projects\closure-compiler>node_modules\openlayers\node_mo
dules\.bin\closure-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:\Roy\websites\php_js_projects\closu
re-compiler\node_modules\openlayers\node_modules\closure-util\lib\compile.js:42:
18)
    at compile (C:\Roy\websites\php_js_projects\closure-compiler\node_modules\op
enlayers\node_modules\closure-util\lib\build.js:94:11)
    at fn (C:\Roy\websites\php_js_projects\closure-compiler\node_modules\openlay
ers\node_modules\closure-util\node_modules\async\lib\async.js:579:34)
    at Immediate._onImmediate (C:\Roy\websites\php_js_projects\closure-compiler\
node_modules\openlayers\node_modules\closure-util\node_modules\async\lib\async.j
s:495:34)
    at processImmediate [as _immediateCallback] (timers.js:358:17)

我没有找到讨论这个问题的谷歌网络搜索或搜索。有解决办法吗?

【问题讨论】:

    标签: openlayers-3 custom-application


    【解决方案1】:

    我今天遇到了这个确切的问题并找到了解决方法。我认为问题在于 OpenLayers 3 在其package.json 中指定了一个过时的closure-util 版本。在 OpenLayers 开发人员自己指定更新版本之前,我发现将closure-util 切换到最新版本为我解决了这个问题。


    解决方法:

    在 OpenLayers 目录下执行以下所有操作(在您的情况下似乎是 C:\Roy\websites\php_js_projects\closure-compiler\node_modules\openlayers)。为保持一致性,我将以下示例引用您的路径:

    1. 打开package.json,查找"dependencies" 部分并将closure-util 的版本从1.5.0 更改为更新的版本(在撰写本文时最新版本为1.7.0)。

      "dependencies": {
          ..
          "closure-util": "1.5.0",
          ..
      },
      

      变成

      "dependencies": {
          ..
          "closure-util": "1.7.0",
          ..
      },
      
    2. 通过从node_modules 目录中删除整个closure-util 目录来删除旧版本的closure-util。 (在你的情况下删除C:\Roy\websites\php_js_projects\closure-compiler\node_modules\openlayers\node_modules\closure-util。)

    3. 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..
      
    4. 再次尝试构建。

      C:\Roy\websites\php_js_projects\closure-compiler>node_modules\openlayers\node_modules\.bin\closure-util build config.json app.js
      

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-09-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-08-08
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多