Node.js Lambda - Using TypeORM with MySql -
i'm trying build lambda's in node.js , using typeorm mysql. have installed required node modules when deploy lambda (via serverless) , test it, errors follows. using gulp build , package .zip.
log output test lambda:
start requestid: 671bed10-81b0-11e7-af34-251688cfdd version: $latest 2017-08-15t11:53:50.594z 671bed10-81b0-11e7-af34-251688cfdd (node:1) unhandledpromiserejectionwarning: unhandled promise rejection (rejection id: 2): driverpackagenotinstallederror: mysql package has not been found installed. try install it: npm install mysql --save 2017-08-15t11:53:50.596z 671bed10-81b0-11e7-af34-251688cfdd method: "get" 2017-08-15t11:53:50.596z 671bed10-81b0-11e7-af34-251688cfdd started .... 2017-08-15t11:53:50.596z 671bed10-81b0-11e7-af34-251688cfdd finished .... 2017-08-15t11:53:50.596z 671bed10-81b0-11e7-af34-251688cfdd (node:1) promiserejectionhandledwarning: promise rejection handled asynchronously (rejection id: 2) 2017-08-15t11:53:50.597z 671bed10-81b0-11e7-af34-251688cfddb2 console error: { driverpackagenotinstallederror: mysql package has not been found installed. try install it: npm install mysql --save @ t.error (native) @ new t (/var/task/index.js:1:48637) @ e.loaddependencies (/var/task/index.js:1:314938) @ new e (/var/task/index.js:1:311241) @ e.createdriver (/var/task/index.js:1:111709) @ e.create (/var/task/index.js:1:104246) @ e.<anonymous> (/var/task/index.js:1:110994) @ r (/var/task/index.js:1:103453) @ object.next (/var/task/index.js:1:102788) @ /var/task/index.js:1:102697 name: 'driverpackagenotinstallederror', message: 'mysql package has not been found installed. try install it: npm install mysql --save' } end requestid: 671bed10-81b0-11e7-af34-251688cfdd report requestid: 671bed10-81b0-11e7-af34-251688cfdd duration: 8.71 ms billed duration: 100 ms memory size: 1024 mb max memory used: 39 mb my research has led me believe won't package correctly because native module. i'm not sure. if there anyway native node modules work lambda's?? appreciated, thanks.
edit
folder structure:
deploy -- dev ---- serverless.yml ---- project.zip -- test ---- serverless.yml ---- project.zip -- prod ---- serverless.yml ---- project.zip node_modules -- * ---- * src -- api ---- user ------ index.ts -- data ---- user.ts -- models ---- user.ts gulpfile.js index.ts package.json tsconfig.json tslint.json gulp file calls function aws-lambda-typescript module has numerous gulp tasks.
const gulp = require('gulp'); const awslambdatypescript = require('aws-lambda-typescript'); awslambdatypescript.registerbuildgulptasks(gulp, __dirname); gulp packages .zip in dist folder , copy deploy>dev , serverless deploy.
thanks help!
most wrong packaging process. i'd check following items:
- check
package.jsonifmysqlthere. - check zip file inside
.serverlessdirectory see if includes node_modules. - download lambda package uploaded , again check if node_modules there.
Comments
Post a Comment