serverless-plugin-include-dependencies icon indicating copy to clipboard operation
serverless-plugin-include-dependencies copied to clipboard

Not adding dependency

Open ghost opened this issue 5 years ago • 5 comments

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: [email protected] /opt/atlassian/pipelines/agent/build +-- [email protected] | +-- [email protected] | +-- [email protected] | | -- [email protected] | +-- [email protected] | | -- [email protected] | +-- [email protected] | +-- [email protected] | | -- [email protected] | +-- [email protected] | | -- [email protected] | | +-- [email protected] | | -- [email protected] | +-- [email protected] | -- [email protected] +-- [email protected] | +-- [email protected] | +-- [email protected] | | +-- [email protected] | | -- [email protected] | +-- [email protected] | | -- [email protected] | +-- [email protected] | +-- [email protected] | +-- [email protected] | +-- [email protected] | +-- [email protected] | +-- [email protected] | +-- [email protected] | | -- [email protected] deduped | +-- [email protected] | | +-- [email protected] deduped | | -- [email protected] | | -- [email protected] | +-- [email protected] | +-- [email protected] | | +-- @types/[email protected] | | -- [email protected] | | -- @types/[email protected] deduped | +-- [email protected] | +-- [email protected] | +-- [email protected] | -- [email protected] | -- @types/[email protected] -- [email protected] +-- [email protected] . . .

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?

ghost avatar Oct 08 '19 11:10 ghost

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.

openam avatar Nov 12 '19 16:11 openam

@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

mpvosseller avatar Jan 08 '20 17:01 mpvosseller

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: [email protected] /opt/atlassian/pipelines/agent/build +-- [email protected] | +-- [email protected] | +-- [email protected] | | -- [email protected] | +-- [email protected] | | -- [email protected] | +-- [email protected] | +-- [email protected] | | -- [email protected] | +-- [email protected] | | -- [email protected] | | +-- [email protected] | | -- [email protected] | +-- [email protected] | -- [email protected] +-- [email protected] | +-- [email protected] | +-- [email protected] | | +-- [email protected] | | -- [email protected] | +-- [email protected] | | -- [email protected] | +-- [email protected] | +-- [email protected] | +-- [email protected] | +-- [email protected] | +-- [email protected] | +-- [email protected] | +-- [email protected] | | -- [email protected] deduped | +-- [email protected] | | +-- [email protected] deduped | | -- [email protected] | | -- [email protected] | +-- [email protected] | +-- [email protected] | | +-- @types/[email protected] | | -- [email protected] | | -- @types/[email protected] deduped | +-- [email protected] | +-- [email protected] | +-- [email protected] | -- [email protected] | -- @types/[email protected] -- [email protected] +-- [email protected] . . .

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?

92nishant avatar Oct 08 '20 18:10 92nishant

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

Sorry!

ZsoltPath avatar Oct 09 '20 08:10 ZsoltPath

@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');

sorjef avatar Jul 12 '21 14:07 sorjef