Pkg: Cannot find module '/snapshot/<My project>/node_modules/mapnik/lib/binding/mapnik_settings.js' after packaging

Created on 29 Apr 2019  路  5Comments  路  Source: vercel/pkg

Hey there :-),
I'm trying to package my application and all works fine, but when I try to run the packaged executable, I get thrown the following error:

Error: Cannot find module '/snapshot/<My Project>/node_modules/mapnik/lib/binding/mapnik_settings.js'
1) If you want to compile the package/file into executable, please pay attention to compilation warnings and specify a literal in 'require' call. 2) If you don't want to compile the package/file into executable and want to 'require' it from filesystem (likely plugin), specify an absolute path in 'require' call using process.cwd() or process.execPath.
    at Function.Module._resolveFilename (module.js:545:15)
    at Function.Module._resolveFilename (pkg/prelude/bootstrap.js:1280:46)
    at Function.Module._load (module.js:472:25)
    at Module.require (module.js:594:17)
    at Module.require (pkg/prelude/bootstrap.js:1159:31)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/snapshot/<My Project>/node_modules/mapnik/lib/mapnik.js:8:16)
    at Module._compile (pkg/prelude/bootstrap.js:1254:22)
    at Object.Module._extensions..js (module.js:661:10)
    at Module.load (module.js:563:32)

I know that this has something to do with the module _Mapnik_, but the file is there and all works fine when running with node.
I've read that this maybe has something to do with paths declared with ___dirname_...?

Most helpful comment

what did you do?

All 5 comments

I resolved the issue. It had nothing to do with pkg, but rather my filestructure.

what did you do?

Hi @clarkx86 ,

What was your file structure issue? To share potential solutions/hints with everyone.

Thanks

This issue seems resolved in https://github.com/zeit/pkg/commit/460ff6c332e157b5f1215267c88d127a9328ebf3 (tho needs checking). So you can use upcoming pkg version instead of restructuring the project (like @clarkx86 did afaiu). @gigouni @AidanWright

Thanks @igorklopov . Would it be in a potential v4.3.5? I saw you've done it 15 days ago, are you waiting for another PR before releasing the version?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

erikd picture erikd  路  3Comments

gillez picture gillez  路  4Comments

ByeongYeon picture ByeongYeon  路  4Comments

jflayhart picture jflayhart  路  4Comments

telunc picture telunc  路  4Comments