Hello all, I'm using sequelize (with mysql, and NO...
# sst
e
Hello all, I'm using sequelize (with mysql, and NOT postgres) and getting the following error on deploy (it works ok locally without any bundle props) :
Building Lambda _function_ src/list.main
> node_modules/sequelize/lib/dialects/postgres/hstore.js:3:23: error: Could not resolve "pg-hstore" (_mark_ it _as_
external
to
_exclude_ it _from_
the
_bundle_, _or_
_surround_ it _with_
_try_/_catch_
to
handle
the
failure
at
_run_-_time_)
3 │ const hstore = require('pg-hstore')({ sanitize: _true_ });
And I've tried putting the module as external_modules as recommended (and also tried node_modules) but with no success in my stack API definition:
defaultFunctionProps: {
bundle: {
node_modules: ['pg-hstore'],
// external_modules: ['pg-hstore'],
// node_modules: ['pg', 'sqlite3', 'tedious', 'pg-hstore']
}
},
Any idea ?
t
It's
nodeModules
you should just need to put it there
e
ok thanks for catching the typo. But now I'm getting :
Cannot extract version for module 'pg'. Check that it's referenced in your package.json or installed.
Any other idea ? I'm indeed not referencing that package since I'm not using it...
t
then you probably don't need to include it in nodeModules
assuming sequelize is built correctly
e
Well that is indeed part of the problem, but putting ph-hstore in externals was the recommended solution : https://github.com/sequelize/sequelize/issues/7509
oh well it seems that simply putting it externalModules instead of nodeModules works... will confirm soon
t
If it absolutely needs pg I'd recommend adding pg as a dep
Listing everything in nodeModules should work
e
Well I guess adding all the modules to my deps would work but it seems stupid to add stuff I don't need...
What do you mean by 'everything' in your last comment ?
So putting pg-hstore in externalModules passes stack building both in local and deployed BUT I'm now getting a new error at runtime when calling my lambda (only on deployed version) :
"Please install mysql2 package manually"
Does this imply that mysql2 needs to be installed as a Lambda layer ?? I'd be surprised since no one else mentioned this...
ok, it's all working good for me now. Here's what worked for me:
Copy code
defaultFunctionProps: {
        bundle: {
          externalModules: ['pg-hstore'],
          nodeModules: ['mysql2']
        }
      },
t
Don't put anything in external modules
Everything needs to be in nodeModules
nodeModules will be copied into the bundle
e
Are you sure ? The key thing here is that I don't have and don't want pg-store (but Sequelize refers to it when bundling, but somehow putting it as external makes it ignored when bundling) but i do need mysql2