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

[BUG] npm ci fails after installing @aws/pdk #755

Closed
tmokmss opened this issue Apr 11, 2024 · 9 comments · Fixed by #756 or #785
Closed

[BUG] npm ci fails after installing @aws/pdk #755

tmokmss opened this issue Apr 11, 2024 · 9 comments · Fixed by #756 or #785
Labels
bug Something isn't working needs-triage stale

Comments

@tmokmss
Copy link

tmokmss commented Apr 11, 2024

Describe the bug

Running npm ci fails after installing pdk.

Similar problem as #381. It seems the issue has been re-introduced somewhere.

Expected Behavior

npm ci successes

Current Behavior

npm ci fails

Reproduction Steps

npm i @aws/pdk
npm ci
# npm ERR! `npm ci` can only install packages when your package.json and package-lock.json or npm-shrinkwrap.json are in sync. Please update your lock file with `npm install` before continuing.

Possible Solution

No response

Additional Information/Context

No response

PDK version used

0.23.30

What languages are you seeing this issue on?

Typescript

Environment details (OS name and version, etc.)

macOS 14.3.1

@tmokmss tmokmss added bug Something isn't working needs-triage labels Apr 11, 2024
@agdimech
Copy link
Contributor

Are you able to please share a sample codebase so I can repro or provide steps to repro?

also have you tried deleting the lock file and running npm install first?

@tmokmss
Copy link
Author

tmokmss commented Apr 13, 2024

@agdimech
You should be able to reproduce it by just running the two commands in the issue description.

More specifically:

$ mkdir pdk-repro
$ cd pdk-repro
$ npm init -y
$ npm install @aws/pdk
$ npm ci
npm ERR! code EUSAGE
npm ERR!
npm ERR! `npm ci` can only install packages when your package.json and package-lock.json or npm-shrinkwrap.json are in sync. Please update your lock file with `npm install` before continuing.

And my environment:

$ npm --version
10.2.3
$ node --version
v20.10.0

also have you tried deleting the lock file and running npm install first?

This issue reproduces right after initializing a project by npm init -y.

@agdimech
Copy link
Contributor

agdimech commented Apr 15, 2024

Thanks for the info.

The issue stems from the fact that bundleDependencies is not super well supported by pnpm (and most package managers) and at pack time, it just adds whatever is currently within the packages node_modules. This is problematic as most of the actual dependencies are stored in the root node_modules. We previously had a script that would link in any missing transitive bundleDependencies but this doesn't handle the case for multiple versions of the same package.

I re-worked all of this to use pnpm deploy which allows you to deploy a package to a new directory and install all deps directly in the node_modules in a flat fashion (similar to npm). This resolves the issues as now multiple package with the same version are correctly included via package node_modules nesting.

Here is the PR: #756

Apologies that you ran into this again, this should fix it once and for all :)

agdimech added a commit that referenced this issue Apr 15, 2024
@tmokmss
Copy link
Author

tmokmss commented Apr 16, 2024

Great to hear that. Looking forward to the new release :)

agdimech added a commit that referenced this issue Apr 17, 2024
@agdimech agdimech reopened this Apr 17, 2024
@agdimech
Copy link
Contributor

Seems that my latest fix isn't working. Upon inspecting the tar.gz there are no nested node_modules however locally I can see them. Will need to investigate into this further to see why the distributable doesn't match. Apologies.

@agdimech
Copy link
Contributor

Been doing some more digging and the actual tgz file looks correct locally, but for some reason it is missing the nested node_modules on the CI publishing workflow. Could potentially be a versioning issue with pnpm/npm, will keep digging.

@agdimech
Copy link
Contributor

agdimech commented May 24, 2024

Have tried multiple fixes on my end to no avail. This is actually a bug with npm as per: npm/cli#6787

The only fix for this at the moment is to either:

  • Use and older version of npm (7.0.8 works) which is the last known version of npm that didn't have the bug 😢
  • run npm i && npm i

Copy link

This issue is now marked as stale because it hasn't seen activity for a while. Add a comment or it will be closed soon. If you wish to exclude this issue from being marked as stale, add the "backlog" label.

@github-actions github-actions bot added the stale label Jul 29, 2024
Copy link

github-actions bot commented Aug 5, 2024

Closing this issue as it hasn't seen activity for a while. Please add a comment @mentioning a maintainer to reopen. If you wish to exclude this issue from being marked as stale, add the "backlog" label.

@github-actions github-actions bot closed this as completed Aug 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs-triage stale
Projects
None yet
2 participants