NPM is not made for large files. My NPM package contains a 800MB SQLite database. I thought I could easily keep it out of the package tarball and require it via URL dependency.
But this dependency rule has to be used for a download of another NPM package tarball. So I will end with just another NPM tarball containing the 800MB database. By keeping it out of the package I would have to put it in another package.
Is this a bad usage of NPM and if yes, what is the best way to install the database file? Important is that NPM takes care of the proper installation and only installs the package if it contains the database.
If you
publish module A in npm
A depends on module B as a URL dependency
You host B yourself at a publicly accessible url
you are not abusing npm registry at all.
Only individual users that choose to use your package A will ever download B, but A is available in npm registry for all to find & make use of.
Related
For a particular case in a Vue.js and JavaScript project a NPM package dependency have to be merge with the current JavaScript code base.
In that specific case, the NPM package should not be part of the nodes_modules folder anymore but rather be part of the JavaScript code itself.
In that case as both codebases will grow together in the future. (Independently from the original NPM package and not as a Fork)
How can I merge or fusion a NPM package to a Javascript project?
Additional Details:
The library that need to be merge is OIDC client. It's an open source project "Archived" by it's author (So no possibility to create Pull Request for a new release).
It is use to create a SSO for an internal project. This library has been retain by architect the for specific need of the project and there is no other option than this one.
There is no "internal package manager" available in this company
I don't want to host the fork on my personal Github and manage the package on NPM website
After many attempt to solve this problem, it turn out that Patch-Package do the best job to merge a dependency by simply patching over instead of forking.
Syntax is pretty simple and it integrate very well with NPM:
Installation: npm i patch-package
Modify the code of your dependency directly in node_modules folder
Run npx patch-package some-package where some-package is the name of your package to patch
https://github.com/ds300/patch-package
Documentation: https://github.com/ds300/patch-package
Is there a way I can download an npm package without having to do a npm view XXX ... or basically just not having to install node/npm? I'm trying to do this on a linux machine.
~EDIT~
I realize I should've added some clarification on what I'm trying to achieve here: all I need are the package's files with dependencies to be served as a static resource on cloudfront. I'm hoping npm provides a way to directly download the artefact like the way maven-central does.
You can access to the raw package using the NPM api.
https://registry.npmjs.org/{package-name}/{version}
The url above will give you a JSON response containing the package metadata. The package property dist.tarball contains an url where the package can be downloaded.
Keep in mind you have to install the dependencies of the package on your own
Example:
https://registry.npmjs.org/lodash/4.17.10
NPM API documentation
Download lib folder from github.com-get all files within it
Put all the files next to your node application in the same folder.
at the top of your file append it like sooo....
var "" = require("./""")
I'd like to know how it works npm comparing to Maven (I come from a Java background) in terms of managing packages.
I have created a generic component using Angular 4, this component will be used in many projects. So, I have published it to our nexus registry and then, from the client projects I just import the package so that the package gets downloaded from the registry and everything works fine.
Now, for development, I don't want to be publishing to the registry every single time I do a modification in the generic component and rebuilding the clients.
I would like instead to do it like we do with Maven in Java, we install the artifact in our local repo, and the artifact will be picked up from the local repo before going to the global 'artifactory', but I see that when we install a module using npm, it gets installed inside node_modules folder inside the same project, so that the module is not available for any other project.
How should I do that? In other words, does npm keep a local repository where the installed modules are accessible to any other projects without the need of publishing to the global registry?
Thanks
use --global switch behind the npm install command to install the package of your choice global.
hope that helps
To make something available to the rest of the system's node package environment through npm, you can install it globally (which is local to your system) rather than locally (which is local to your project). You can see documentation for global-ness on installs in this part of the NPM documentation.
npm i -g package names here
npm install --global package names here
You can update your globally installed packages as you would a locally installed one as well when you need to.
npm update -g package names here
(or all of them without specifying)
npm update -g
See the full NPM documentation pages for more detailed flags, etc.
If you're hoping to use your own packages in a managed environment, you can either publish them as private modules or keep them in a VCS (mostly git) and reference them by the appropriate method for that VCS in your projects' package.json scheme through the dependencies block for github urls or more generally other git hosts, like
"dependencies": {
"myComponent": "user/repo#feature\/branch",
"otherComponent": "git+https://myGitHost.tld/.../projectName.git#commit"
}
I would like to create local npm registry with sinopia and then publish there all packages from my projects node_modules directory. Effectively I want to be able to run npm install --registry="http://localhost:4873" in my project offline and get all the needed dependencies from local registry. Is there a simple way of doing this?
sinopia will cache registries that it pulls from npmjs.org by default.
If you set up your registry to use your sinopia one, then do a clean npm install (delete node_modules prior to running it) through it (while sinopia is connected to the internet), it should pull down all of the packages from npmjs.org and cache them.
After that, subsequent calls with sinopia disconnected should use the one it has cached locally and work as intended.
My network doesn't allowed using npm install.
How can I install and use nodemon? Node run only after set PATH variables on windows I tried set the path for nodemon, but I dont have results.
The easiest way to install an npm package is going to be to either tunnel out of your network with a proxy, or to simply install the package while you're on a different network. The reason it's not as simple to just download it is that npm packages have a list of dependencies that need to be installed along with it. Npm takes care of installing the dependency graph for you. If you try to install it manually you would have to manually go over nodemon's package.json file and install all of its dependencies. That might not be so bad until you realize that you then have to go through all those dependencies and install their dependencies, and so on...
I'm not at all affiliated with IPVanish but I recently signed up for their service for the same reason as you. My computer has a VPN configured that connects to an IPVanish server and then my computer tunnels all internet traffic through that VPN. It's nice for simple anonymous web browsing, but more importantly there is no way for network admins here to see where any of my traffic is going. To them it appears that I'm just talking to a random server. They'd have to block every single IPVanish server (and there's a lot!).
There are other alternatives but that one had good reviews and it's only $10 a month. I haven't tried any others but I'm sure they're just as good.
If tunneling out of your network or installing the module on a different network isn't an option, I'm happy to install it myself and upload a zip of the completed install to Google Drive so you can just extract it to the global npm folder. However, that would obviously not be a permanent solution for you and even though I have good intentions, you don't know me and I don't recommend downloading random stuff off of a stranger's Google Drive.
I recommend getting a friend to do the following from another network:
Install nodemon: npm install -g nodemon
Find where global npm modules install to: npm config get prefix
Navigate to the global npm module path, find the nodemon directory, and zip it up.
Email/Dropbox you the archived module.
On your machine figure out where global npm modules install to: npm config get prefix
Extract the nodemon zip to that location.