ibesora / vt-optimizer

A small NodeJS cli tool to inspect and optimize Mapbox Vector Tiles files
MIT License
65 stars 12 forks source link

'Listr' and 'Pbf' not resolved in my environment. #1

Closed hfu closed 5 years ago

hfu commented 5 years ago

Hi @ibesora. Thanks for a great tool. When I install vt-optimizer and run it, the module 'Listr' and 'Pbf' were not found in my RedHat environment.

$ git clone git@github.com:ibesora/vt-optimizer
$ cd vt-optimizer
$ npm install
$ node index.js
internal/modules/cjs/loader.js:583
    throw err;
    ^

Error: Cannot find module 'Listr'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:581:15)
    at Function.Module._load (internal/modules/cjs/loader.js:507:25)
    at Module.require (internal/modules/cjs/loader.js:637:17)
    at require (internal/modules/cjs/helpers.js:20:18)
    at Object.<anonymous> (/home/fhidenori/vt-optimizer/src/core/VTProcessor.js:5:15)
    at Module._compile (internal/modules/cjs/loader.js:689:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
    at Module.load (internal/modules/cjs/loader.js:599:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
    at Function.Module._load (internal/modules/cjs/loader.js:530:3)

My tentative workaround was to symlink listr -> Listr and pbf -> Pbf in node_modules. Then vt-optimizer seems working in my environment, too.

$ cd node_modules
$ ln -s listr Listr
$ ln -s pbf Pbf
$ cd ..
$ node index.js -h
... it works! ...

I guess we can solve this problem if we change the following lines.

https://github.com/ibesora/vt-optimizer/blob/227f9f7d1690b0ec17dce26b68c099d45eda3ce7/src/core/VTProcessor.js#L5

https://github.com/ibesora/vt-optimizer/blob/227f9f7d1690b0ec17dce26b68c099d45eda3ce7/src/core/VTWriter.js#L5

Although I am not sure about how Node.js shall behave in this case, but how do you think about de-capitalizing the strings inside require() above? I can send a pull request if you like.

FYI, my node version is v10.10.0.

$ node -v
v10.10.0

Cheers :smiley:

ibesora commented 5 years ago

Commit 7d17c7a fixes this. Sorry about that. Travis runs Ubuntu and it wasn't a problem on that distribution.

hfu commented 5 years ago

Thanks! I confirmed that the latest master works good with my environment, too. :+1: