henhal / serverless-plugin-layer-manager

Plugin for the Serverless framework that offers improved AWS Lambda layer management
MIT License
12 stars 8 forks source link

Bugfix: Process stuck at Excluding development dependencies... #4

Closed piotr-cz closed 4 years ago

piotr-cz commented 4 years ago

After installing this plugin the sls package command gets stuck at the Excluding development dependencies... state.

This happens for both my project and example application bundled with this repo:

> sls package
[layer-manager] Invoking layer-manager plugin
+ example-layer-service@1.0.0
added 2 packages from 3 contributors in 0.538s
[layer-manager] Installed 1 layers
Serverless: Packaging service...
Serverless: Excluding development dependencies...

I'm using Windows OS and assuming that it happens only on this OS as there are no similiar bug reports.

I found out that the problem may be due to the working directory where npm install is being run.

When it's executed with the --prefix option, npm adds a symbolic link inside the layers node_modules that points to the service directory at it seems that this is where the process gets stuck:

- my-lib
  - nodejs
    - node_modules
      - example-layer-service (symlink)
      - lodash
    package.json
    package-lock.json
hello.js
package.json
package-lock.json
serverless.yml

When switching to cwd instead of --prefix, it doesn't get stuck anymore.

henhal commented 4 years ago

Thanks for the PR, @piotr-cz! I had indeed not tested on Windows. This change makes perfect sense and I've verified that it still works as intended also on Linux. I will merge and release 1.0.4 shortly.

piotr-cz commented 4 years ago

Just a note: as npm install is executed in target directory, it's also possible to use dedicated .npmrc file there.