Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NPM: Missing dist and src directories when trying to install directly from a github url

An npm package I am using has been forked on github with some bug fixes and I now want to use the forked code in my project until the fork is merged.

In my package.json I change the reference in dependencies from e.g. “cool-package”: "^0.10.0" to “cool-package“: "git://github.com/developer-who-forked/cool-package.git" but this doesn’t work.

If I run npm install after updating the package.json and then go in to node_modules/cool-package/ I don’t see any /src folder or any /dist folder (all the other modules installed via normal npm seem to have at least a /dist folder).

I only see an /example folder and a /test folder alongside a package.json and a README.md. If i’d installed the package by including “cool-package”: "^0.10.0" there would be the src/ and dist/ folders.

The forked repo, or the original repo it was forked from don’t have a /dist folder - it is actually in the .gitignore file. So I think I am missing some build step that is required to create the /dist files when trying to access github repos directly in the package.json.

like image 301
Tech 75 Avatar asked Aug 31 '25 18:08

Tech 75


2 Answers

What worked for me was:

  1. commiting /dist to gh
  2. running npm install {username}/{repo}.git instead of manually adding the record to package.json
like image 62
nikksan Avatar answered Sep 02 '25 11:09

nikksan


Just Answered the Question Based on Comments:


I run npm run-script build and helped me!

Why it worked -

The issue when installing an npm package directly from a GitHub URL: the missing build step. When you install a package from npm, it's usually already built and compiled, meaning it has the /dist directory with the production-ready code. However, when you pull directly from GitHub, you're getting the raw source code, which often doesn't include the compiled /dist directory (as it's typically in .gitignore).

like image 40
kian Avatar answered Sep 02 '25 10:09

kian