0

I am trying to build a custom application of openlayers-3 on Windows 7 using the Compiling Application with Closure Compiler tutorial. When running the closure-util build option I get the following:

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)

I don't find google web searches or searches here discussing this problem. Is there a workaround?

1 Answers1

0

I had this exact problem today and found a workaround. I believe the problem is that OpenLayers 3 ships with an outdated version of closure-util specified in its package.json. Until the OpenLayers devs specify the newer version themselves, I found that switching out closure-util to the latest version solved this problem for me.


Workaround:

Do all of the following under the OpenLayers directory (appears to be C:\Roy\websites\php_js_projects\closure-compiler\node_modules\openlayers in your case). For consistency, I've made the examples below refer to your path:

  1. Open package.json, look for the "dependencies" section and change the version of closure-util from 1.5.0 to a newer version (the latest is 1.7.0 at the time of this writing).

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

    becomes

    "dependencies": {
        ..
        "closure-util": "1.7.0",
        ..
    },
    
  2. Remove the old version of closure-util by deleting the entire closure-util directory from the node_modules directory. (Delete C:\Roy\websites\php_js_projects\closure-compiler\node_modules\openlayers\node_modules\closure-util in your case.)

  3. Run npm install while inside the openlayers directory. This will make the node package manager automatically retrieve the latest version of closure-util to replace the one we deleted in the previous step.

    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. Try your build again.

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