dougmoscrop / serverless-plugin-include-dependencies

MIT License
184 stars 40 forks source link

Not adding dependency #43

Open ghost opened 4 years ago

ghost commented 4 years ago

Hi,

I have a strange case. In my package.json I have: "dependencies": { "mysql2": "^1.6.4", "sequelize": "^4.41.2" },

When I run "npm list" before "sls deploy" I get this: crumbs_api@1.0.0 /opt/atlassian/pipelines/agent/build +-- mysql2@1.7.0 | +-- denque@1.4.1 | +-- generate-function@2.3.1 | |-- is-property@1.0.2 | +-- iconv-lite@0.5.0 | | -- safer-buffer@2.1.2 | +-- long@4.0.0 | +-- lru-cache@5.1.1 | |-- yallist@3.1.1 | +-- named-placeholders@1.1.2 | | -- lru-cache@4.1.5 | | +-- pseudomap@1.0.2 | |-- yallist@2.1.2 | +-- seq-queue@0.0.5 | -- sqlstring@2.3.1 +-- sequelize@4.44.3 | +-- bluebird@3.7.0 | +-- cls-bluebird@2.1.0 | | +-- is-bluebird@1.0.2 | |-- shimmer@1.2.1 | +-- debug@3.2.6 | | -- ms@2.1.2 | +-- depd@1.1.2 | +-- dottie@2.0.1 | +-- generic-pool@3.5.0 | +-- inflection@1.12.0 | +-- lodash@4.17.15 | +-- moment@2.24.0 | +-- moment-timezone@0.5.26 | |-- moment@2.24.0 deduped | +-- retry-as-promised@2.3.2 | | +-- bluebird@3.7.0 deduped | | -- debug@2.6.9 | |-- ms@2.0.0 | +-- semver@5.7.1 | +-- terraformer-wkt-parser@1.2.0 | | +-- @types/geojson@1.0.6 | | -- terraformer@1.0.9 | |-- @types/geojson@1.0.6 deduped | +-- toposort-class@1.0.1 | +-- uuid@3.3.3 | +-- validator@10.11.0 | -- wkx@0.4.8 |-- @types/node@12.7.11 -- serverless-plugin-include-dependencies@3.2.1 +-- glob@7.1.4 . . .

But when the package deployed it doesn't have the mysql2 module.

I've tried to add `custom: includeDependencies: always:

Error: [serverless-plugin-include-dependencies]: Could not find cardinal at handle (/opt/atlassian/pipelines/agent/build/node_modules/serverless-plugin-include-dependencies/get-dependency-list.js:52:17)

Seems like mysql2 has an optional dependency of cardinal and that's causing the issue at the second time. Maybe it's the reason why it isn't included automatically.

Could you help me figuring this out?

openam commented 4 years ago

I have a project that's using the config package. It gets added properly when I'm using node 8 (8.11.4), but when I tried to upgrade to node 10 (10.16.3) it quit including that package.

mpvosseller commented 4 years ago

@openam I don't think your issue is related to this. I filed a new ticket for your issue here: https://github.com/dougmoscrop/serverless-plugin-include-dependencies/issues/46

92nishant commented 3 years ago

Hi,

I have a strange case. In my package.json I have: "dependencies": { "mysql2": "^1.6.4", "sequelize": "^4.41.2" },

When I run "npm list" before "sls deploy" I get this: crumbs_api@1.0.0 /opt/atlassian/pipelines/agent/build +-- mysql2@1.7.0 | +-- denque@1.4.1 | +-- generate-function@2.3.1 | |-- is-property@1.0.2 | +-- iconv-lite@0.5.0 | | -- safer-buffer@2.1.2 | +-- long@4.0.0 | +-- lru-cache@5.1.1 | |-- yallist@3.1.1 | +-- named-placeholders@1.1.2 | | -- lru-cache@4.1.5 | | +-- pseudomap@1.0.2 | |-- yallist@2.1.2 | +-- seq-queue@0.0.5 | -- sqlstring@2.3.1 +-- sequelize@4.44.3 | +-- bluebird@3.7.0 | +-- cls-bluebird@2.1.0 | | +-- is-bluebird@1.0.2 | |-- shimmer@1.2.1 | +-- debug@3.2.6 | | -- ms@2.1.2 | +-- depd@1.1.2 | +-- dottie@2.0.1 | +-- generic-pool@3.5.0 | +-- inflection@1.12.0 | +-- lodash@4.17.15 | +-- moment@2.24.0 | +-- moment-timezone@0.5.26 | |-- moment@2.24.0 deduped | +-- retry-as-promised@2.3.2 | | +-- bluebird@3.7.0 deduped | | -- debug@2.6.9 | |-- ms@2.0.0 | +-- semver@5.7.1 | +-- terraformer-wkt-parser@1.2.0 | | +-- @types/geojson@1.0.6 | | -- terraformer@1.0.9 | |-- @types/geojson@1.0.6 deduped | +-- toposort-class@1.0.1 | +-- uuid@3.3.3 | +-- validator@10.11.0 | -- wkx@0.4.8 |-- @types/node@12.7.11 -- serverless-plugin-include-dependencies@3.2.1 +-- glob@7.1.4 . . .

But when the package deployed it doesn't have the mysql2 module.

I've tried to add custom: includeDependencies: always: - 'node_modules/mysql2/**' to serverless.yaml, but then I've got the following error while building the package:

Error: [serverless-plugin-include-dependencies]: Could not find cardinal at handle (/opt/atlassian/pipelines/agent/build/node_modules/serverless-plugin-include-dependencies/get-dependency-list.js:52:17)

Seems like mysql2 has an optional dependency of cardinal and that's causing the issue at the second time. Maybe it's the reason why it isn't included automatically.

Could you help me figuring this out?


@KundK I'm facing the same issue. Have you found the solution?

ZsoltPath commented 3 years ago

@92nishant I have, but can't remember exactly what was it. And I don't have access to that code anymore.

Sorry!

sorjef commented 3 years ago

@92nishant you may try adding something similar in your handler. This fixed it for me:

// DO NOT REMOVE.
// serverless include dependencies plugin removes mysql2 required by knex
// this is added to ensure this dependency is included
// eslint-disable-next-line no-unused-vars
const mysql2 = require('mysql2');