dougmoscrop/serverless-plugin-include-dependencies

Version 5.0.0 does not include node modules

talaikis opened this issue · 8 comments

Version 5.0.0 stopped including required packages from node_modules.

I had to roll back to v4.1.0

I only face this issue on my Windows PC. On a MacBook pro version 5.0.0 works just fine.
I also rolled back to 4.1.0

I'm also on Windows 10 and v5.0.0 didn't work for me.
v4.1.0 worked out of the box.

I tried rolling back to v4.1.0 and it didn't work for me. I'm still missing the pg package (and probably others). Is there some basic configuration I'm not understanding?

I tried rolling back to v4.1.0 and it didn't work for me. I'm still missing the pg package (and probably others). Is there some basic configuration I'm not understanding?

Are you using sequelize? I can't find the link, but I remember having an issue when trying to use pg and sequelize together. To fix it, I had to add an extra "const pgUnecessary = require('pg');" to a file in my project. That forced the packager to add that package. Otherwise it just included the sequelize packages.

Data: I believe our team had success on Windows by switching from package.include and package.exclude to package.patterns. We're running v5.

I'm having this issue with a project (Windows 10). I've used this plugin at work and it is awesome. It adds all the needed dependencies. On this new small project, I had to use the package.patterns to manually add the packages.

At work, my projects seem to add all of them automatically. At work, there is a set of additional serverless tools. Maybe that is what is adding them?

Is it expected to have the packages automatically added to the zip file that is uploaded?

As pointed in #75 for some reason glob is not included in dependencies, though it's obviously used in the code.

There is a chance you already have glob installed as a dep of some other package, or you may work around #75 by doing npm i --save-dev glob.

In this case it seems to work but on Windows you would miss node_modules as outlined in this issue's topic.

The reason is that you have glob@8 installed, which has a breaking change for Windows by treating \ in paths differently from what glob@7 does. Using glob@8 strips all node_modules paths as because of the way path is constructed, on Windows this path would contain backslash \ ignored by glob@8 .

TL;DR:

  • if you experience #75 (=Error: Cannot find module 'glob'), just install glob@7:
npm i --save-dev glob@7.2.3
  • in case you have glob@8 installed and required by some other package, kindly ask @dougmoscrop to release a new version with glob^7.2.3 explicitly specified as a dependency for serverless-plugin-include-dependencies, so it could nicely work on Windows.