You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'd like better support for NPM/Yarn workspaces.
Currently a package-lock.json or npm-shrinkwrap.json file present in the CodeUri for your Lambda function is expected. When using UseNpmCi it's required and sam build will fail with this cryptic error
Note that package-lock.json and node_modules are only present in the root.
Proposal
sam-cli should take NPM workspaces into consideration. I'm sure some clever things can be done when multiple lambdas are in a NPM workspace as npm i or npm ci only need to be run once for all node_modules to be installed for all package.json files in the workspace. I believe build can be sped up significantly.
Furthermore the requirement for a package-lock.json or npm-shrinkwrap.json file present in the CodeUri is not true for NPM workspaces. Instead it's required at the NPM workspace root.
Actually running npm i or npm ci in a workspace project, fx ~/<root>/lambdas/lambda-a/> npm ci will do the right thing and install packages in ~/<root>/node_modules/ which is very useful!
This might be a bit of a loose proposal but the goal here is to make it work with NPM workspaces. Not only should it work instead of fail, it should utilize the features of NPM workspaces to speed up build time.
Additional Details
The text was updated successfully, but these errors were encountered:
@snebjorn Thanks for the report. Looks like a change in Lambda Builders that broke this. I don't think this has anything to do with NPM workspaces. I would like to focus this issue on the bug. Once patched, if there is still something missing on the Workspace front, I would ask you to create a new issue so we can scope them correctly.
Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.
Describe your idea/feature/enhancement
I'd like better support for NPM/Yarn workspaces.
Currently a package-lock.json or npm-shrinkwrap.json file present in the CodeUri for your Lambda function is expected. When using
UseNpmCi
it's required andsam build
will fail with this cryptic errorWhen using an NPM workspace the folder structure might look like this:
Note that
package-lock.json
andnode_modules
are only present in the root.Proposal
sam-cli
should take NPM workspaces into consideration. I'm sure some clever things can be done when multiple lambdas are in a NPM workspace asnpm i
ornpm ci
only need to be run once for all node_modules to be installed for all package.json files in the workspace. I believe build can be sped up significantly.Furthermore the requirement for a package-lock.json or npm-shrinkwrap.json file present in the CodeUri is not true for NPM workspaces. Instead it's required at the NPM workspace root.
Actually running
npm i
ornpm ci
in a workspace project, fx~/<root>/lambdas/lambda-a/> npm ci
will do the right thing and install packages in~/<root>/node_modules/
which is very useful!This might be a bit of a loose proposal but the goal here is to make it work with NPM workspaces. Not only should it work instead of fail, it should utilize the features of NPM workspaces to speed up build time.
Additional Details
The text was updated successfully, but these errors were encountered: