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] When installing a git dependency, prepare script not running #3800

Closed
1 task done
OmgImAlexis opened this issue Sep 26, 2021 · 9 comments
Closed
1 task done
Labels
Release 7.x work is associated with a specific npm 7 release Wontfix this will not be worked on

Comments

@OmgImAlexis
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

Package is installed and no dist directory is created.

Expected Behavior

  • Package is installed, prepare script is run and dist directory is created.

Steps To Reproduce

This should show dist missing in the ls even though it has a prepare script.

  • mkdir x && cd x && npm init -y
  • npm i github:omgimalexis/interval-to-human
  • ls node_modules/interval-to-human/

If you then run cd node_modules/interval-to-human/ && npm i && npm run prepare && cd ../../ you'll see the dist directory now exists.

Environment

  • OS: Windows/macOS/linux
  • Node: v14.15.3
  • npm: 6.14.5 - 7.24.1
@OmgImAlexis OmgImAlexis added Bug thing that needs fixing Needs Triage needs review for next steps Release 7.x work is associated with a specific npm 7 release labels Sep 26, 2021
@OmgImAlexis
Copy link
Author

OmgImAlexis commented Sep 26, 2021

Related issues:

#321
#459
#1229
#1287
#1390

@Raynos
Copy link
Contributor

Raynos commented Sep 27, 2021

Ran into this today.

@gms-ta-koge
Copy link

It might be related to #2890

@OmgImAlexis
Copy link
Author

@gms-ta-koge doubt it since it also happens in 6 and they state they can downgrade to fix it.

@OmgImAlexis
Copy link
Author

So...

v14 - the prepare isn't called.
v15 - the dev deps aren't installed.
v16 - the dev deps aren't installed.
v17 - fails with path null/package.json

@OmgImAlexis
Copy link
Author

Does any version of node have a copy of npm that works with git and global packages?

@ruyadorno
Copy link
Contributor

ruyadorno commented Feb 24, 2022

Thank you for the report @OmgImAlexis, after debugging the reproduction steps provided I noticed that the error you're finding is due to the fact that your dist/ folder is in fact ignored via .gitignore file.

In order to be able to properly prepare a git repo npm will run the extracted files through npm-packlist in order to get the expected files that are going to be placed in your node_modules folder.

To fix it either add a .npmignore file that ignores all the files that you don't want to end up in your tarball (but make sure to not add dist to the list) OR instead use the package.json files property to define all files that should be included (including dist).

Thanks again and hope this helps 😊

@ruyadorno ruyadorno added Wontfix this will not be worked on and removed Needs Triage needs review for next steps Bug thing that needs fixing labels Feb 24, 2022
@OmgImAlexis
Copy link
Author

Time to add a warning to all my repos that're missing the files field. This fixed the issue.

@ljharb
Copy link
Contributor

ljharb commented Feb 25, 2022

Or .npmignore; omission from “files” means your consumers break; omission from npmignore means an extra thing gets published.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Release 7.x work is associated with a specific npm 7 release Wontfix this will not be worked on
Projects
None yet
Development

No branches or pull requests

5 participants