claudiajs / claudia

Deploy Node.js projects to AWS Lambda and API Gateway easily
https://claudiajs.com
MIT License
3.8k stars 276 forks source link

--no-optional-dependencies not working as expected #216

Closed http417 closed 2 years ago

http417 commented 4 years ago

Please use GitHub issues only to report bugs. To ask a general question or request assistance/support, please use the Claudia.js Gitter Chat instead.

To report a bug or a problem, please fill in the sections below. The more you provide, the better we'll be able to help.


if I remove the --no-package-lock option, then the optional dependencies are correctly omitted.

jugglingcats commented 3 years ago

Related to #82 which seems to have gone stale.

@gojko when I run npm i --production --no-optional, the aws-sdk doesn't appear anywhere under node_modules for me but still appears in my package. Am sure this was working fine in the past.

jugglingcats commented 3 years ago

Possibly an npm version issue or something else in local environment. Have just looked at the package created as part of deployment (using Github action) and it doesn't contain aws-sdk! Maybe a Windows issue?

danomatic commented 3 years ago

After battling this for hours today, I THINK the issue is the npm dedupe. You can reproduce with:

rm -rf package-lock.json node_modules
npm install --no-optional --production

At this point aws-sdk is not installed

npm dedupe --no-optional --production

Still not installed

npm dedupe

Now it's installed

Running claudia update with --no-optional-dependencies does not apply --no-optional --production when running npm dedupe

This is a total blocker for me. The size of the bundle is so large that my deploys are failing now.

danomatic commented 3 years ago

^ this is with latest Node (14). After downgrading to 13, claudia update no longer fails due to size (from aws-sdk and others).

danomatic commented 3 years ago

More specifically, it's NPM 7 where Claudia has the issue with dedupe. It should be fixed to add the --no-optional --production flags. In the meantime, the workaround is to install NPM 6:

npm install -g npm@^6
lehno commented 3 years ago

Any resolution on this?

danielg-cf commented 3 years ago

Fixed. PR is pending #225.

gojko commented 2 years ago

thanks, this is now published as v 5.14.0