Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not adding dependency #43

Open
ghost opened this issue Oct 8, 2019 · 5 comments
Open

Not adding dependency #43

ghost opened this issue Oct 8, 2019 · 5 comments
Assignees

Comments

@ghost
Copy link

ghost commented Oct 8, 2019

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?

@dougmoscrop dougmoscrop self-assigned this Oct 8, 2019
@openam
Copy link

openam commented Nov 12, 2019

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
Copy link

@openam I don't think your issue is related to this. I filed a new ticket for your issue here: #46

@92nishant
Copy link

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?

@ZsoltPath
Copy link

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

Sorry!

@sorjef
Copy link

sorjef commented Jul 12, 2021

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants