- #Npm install from github project that uses release script install
- #Npm install from github project that uses release script update
#Npm install from github project that uses release script install
The -only= argument will cause either only devDependencies or only non-devDependencies to be installed regardless of the NODE_ENV.Ī better solution, in my opinion, is to use: npm install Īnd then inside package.At Insight we have customer-facing applications which often share a lot of conceptual functionality. Note: But if you want a specific version of the package (production/dev) with or without dev dependencies you can install it via: The libs used to build the app - babel etc will not be installed. "install": "npm run build"īut this will run an install for everyone downloading the module from npm right? This is hugely problematic given that dev dependencies will not be installed for anyone downloading the module from npm.
![npm install from github project that uses release-script npm install from github project that uses release-script](https://github.githubassets.com/images/modules/site/home/actions-editor.png)
![npm install from github project that uses release-script npm install from github project that uses release-script](https://frontity.org/wp-content/uploads/2020/10/Screen-Shot-2020-10-26-at-11.49.24.png)
Heck, I know that problem when you have a troublesome files that you have to include inside repo but never modify them, or sometimes remove? That's just sick.Īs Tinker mentioned there exist ability for a package to execute a command when installed. Rebasing and merging is even more annoying. When I was working with a microservices-based project that has about 5 standalone subprojects divided into modules the problem that I found an issue, fixed it and forget to publish in every place I had to was really annoying.ĭon't want to push lib into the repo, because it's derived from sources Sometimes it's too much pain to fix a small bug, then push to the repo and forget to publish on npm. The main issues we are facing here are the following ones: Results of invoking npm install dumb-package: This little hack with file ThisIsNpmPackage makes the source detection available. Note that npm publish can be automated via CI tools - githooks When publishing I do git push and npm publish (npm install will recursively invoke install hook) File AlreadyInstalled is generated to prevent infinite looping (this will ensure we have devDependencies. Install hook it's just a piece of bashy script to check if ThisIsNpmPackage exists. The idea is to make file ThisIsNpmPackage available on the repo, but not in npm package. build.js ) || echo \"SKIP: NON GIT SOURCE\"" I didn't understand the question properly.īelow are things that I wrote but are a bit off-topic.įor now if you want to run build.js only when installing from repo: Note: I also reached out to NPM's support regarding this issue and I'll add their response if I receive one.Įdit: Detecting if the package is being installed from git repo
#Npm install from github project that uses release script update
I want to consume the latest version of the module without having to push out a release to NPM whenever I update the codebase - I would rather push out fewer releases when I am ready, but I still need to consume whatever the latest version of the lib is on Github. My usecase is that I am developing a module that is used in a number of other projects. From this issue it is clear that using prepare is not the answer. There is a closed issue on NPM's Github with no resolution - just lots of people who want a solution. So every you push to master the project also builds and pushes to a separate branch. I guess this could be automated with a githook though. gitignore and remove dir from git.īut that is far from ideal. When you are ready for a PR / rebase add lib/ dir to.I am aware of one strategy to deal with this problem: There is not only no reason to force a build when people install from npm, but more importantly, development dependencies will not be installed (for example babel which is critical to the build). In short, yes they allow you to build on install, but they don't allow you to build on install from github only. There are now prepublish, prepublishOnly and prepare lifecycle hooks, but none provide an answer to this problem because they don't allow any way to differentiate between the source of the install.
![npm install from github project that uses release-script npm install from github project that uses release-script](https://i.stack.imgur.com/uQAFn.png)
This means the package needs to built (just as it would be before release), only this time locally so that the lib directory (or whatever other files are generated during the build process) are added to the module's directory.Īssuming there is a build script within the package.json file's scripts field, can the package be configured to run this automatically in the situation where it is installed from github only? If not, what is the the best approach to ensuring it is built when installed from github? When installing a package from the project's github (during development for example) the lib/ dir will not exist, so if the package's package.json's main field points to (for example) lib/index.js, the package cannot be compiled when imported because these files do not exist within the repository and therefore within the package installed into node_modules. Given that a project's lib/ dir shouldn't be checked into Git because the files it contains are derived files (from the build process).