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] Dependencies installed with a git URL commit does not contain the folders of the package #5130

Closed
2 tasks done
Flaburgan opened this issue Jul 7, 2022 · 2 comments
Closed
2 tasks done
Labels
Bug thing that needs fixing Needs Triage needs review for next steps Release 8.x work is associated with a specific npm 8 release

Comments

@Flaburgan
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

This issue exists in the latest npm version

  • I am using the latest npm

Current Behavior

This has already been reported a while ago: npm/npm#15654

When installing a dependency from a git commit, the folders aren't downloaded.

Expected Behavior

node_modules/my_dependency should contain not only package.json but also the src folders

Steps To Reproduce

This started because react-block-ui package isn't maintained anymore and is stuck with React 16. I wrote a merge request Availity/react-block-ui#65 to say it also works with React 17. But waiting for it to be integrated, I wanted to use my own version of react-block-ui with my patch, available at Flaburgan/react-block-ui@0feb0f1

Here is my package.json file:

{
  "name": "XXX",
  "version": "2.4.0",
  "private": true,
  "dependencies": {
    (...)
    "react": "^17.0.2",
    "react-block-ui": "git+https://github.com:Flaburgan/react-block-ui#0feb0f14514d58ed98fc4943f0aab8db19d475e4",
    "react-dom": "^17.0.2"
  }
 (...)
}

And same change in package-lock.json.

When I run npm install and then navigate to node_modules/react-block-ui, I have the files (CHANGELOG, LICENCE, package.json (which contains my patch) and README) but I miss some other files, and especially I don't have the folders (src and scripts), so obviously nothing is working.

Environment

  • npm: 8.5.1, 7.20.x, 7.5.x
  • Node.js: 16
  • OS Name: Ubuntu 21.10, 22.04, Windows 10
@Flaburgan Flaburgan added Bug thing that needs fixing Needs Triage needs review for next steps Release 8.x work is associated with a specific npm 8 release labels Jul 7, 2022
@ljharb
Copy link
Contributor

ljharb commented Jul 7, 2022

Does it declare an npmignore that prevents publishing of those files? npm install wouldn’t include those.

Generally speaking, git is for dev, not consumption, so you can’t rely on installing from git working.

@nlf
Copy link
Contributor

nlf commented Jul 13, 2022

this one's a bit confusing, but what you're seeing is correct. allow me to explain:

the files array in the package.json lists the lib and dist directories, along with a few other files. when you clone the repository, however, those files don't exist. you must run the build script to create them.

build is not a built-in script for npm, so we don't run it for you. what's happening is we're cloning the repository, then we're running (essentially) npm i && npm pack in the cloned directory. if you try this with a fresh checkout you'll find that you get the same result as you do when installing it as a dependency right now.

to fix this, the short path would be to add a prepare script like "prepare": "npm run build". we do run the prepare script for you, if it exists, so making that change will let npm build your project before it tries to pack it and install it as a dependency.

@nlf nlf closed this as completed Jul 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug thing that needs fixing Needs Triage needs review for next steps Release 8.x work is associated with a specific npm 8 release
Projects
None yet
Development

No branches or pull requests

3 participants