Is there an alternative for npmzip? - node.js

As mentioned by #NS Gopikrishnan in this question there was an npmzip tool that we could use to create npm install packages that include all dependancies for that package.
Unfortunately npmzip is no longer available.
I would be very interested in creating offline install packages that include all dependancies. Does anyone know of an alternative to npmzip that does this for me?

According to #kamil's answer in this question there's indeed an alternative to npmzip. It is called npmbox

In online environment, npm install --no-bin-link. You will have a entire flattened node_modules
Then, bundle this flawless node_modules with tar / zip / rar / 7z etc
In offline environment, extract the bundle, that's it
P.S node-pac is another option, but it can't deal with the packages which still need downloading something for installation.

Related

How to create offline installer for node packages?

I wanted to know if it's possible to just install a package globally (for ex: ExpressJS) and then when I want to add it to a specific folder/project. I can just install a copy from the global package instead of installing it from the internet again.
How do I do this?
I saw another thread here and it says to create a tarball using npm pack which creates a tarball file but I don't know how to install a tar.gz as a package. I'm new to npm.
The reason I need this is because my internet is metered and very slow. If possible I want to download packages only once then just reuse it again on other projects.
You can use npm i <filename-which-ends-with.tar.tz> eg. npm i my-pack.tar.tz

indicate in which folder to install a packages npm

I'm getting closer to npm to manage the javascript of my project.
Looking at stackoverflow I saw this documentation: https://docs.npmjs.com/using-npm-packages-in-your-projects
but honestly I understood little and nothing...
I would like to install this package: npm install lightgallery lg-thumbnail lg-autoplay lg-video lg-fullscreen lg-pager lg-zoom lg-hash lg-share
running it he will put the package in node_modules.
always looking at the documentation I found: npm install <folder>, so I tried an told path to the directory at the end of npm install, but the install it inside the node_modules folder...
I'm using Laravel, and if I want to install something from npm to public/inc/plugins, which is the correct procedure? is it possible to indicate this in the packages.json file? If it is recommended to use the installation in the main node, how can I then use the js? with a reconstruction with webpack mix?
You shouldn't do that, because this is standard, and other developers may feel uncomfortable if you change this behavior.
In documentation, you can find:
Install the package in the directory as a symlink in the current project. Its dependencies will be installed before it’s linked. If folder sits inside the root of your project, its dependencies may be hoisted to the toplevel node_modules as they would for other types of dependencies.
Here you can find an answer on StackOverflow

How to use one node_modules for all projects

Is there an easy way to share one node_modules folders with all angular projects and thus avoiding to download same dependencies every-time when we create a new project ?
if yes , is the method recommended ( what are pros/cons)
Thanks for your time
Package Managers namely npm and yarn have caching mechanism.
The packages are download for the first time only and when you run the install command for the already downloaded package, they won't be downloaded again.
That being said even if you don't have an internet connection you can still install previously cached packages.
Yarn is particularly awesome on handling this and npm is now catching up.
This solves your problem of downloading the packages again. Do lock your package dependencies version. This might help in using the same node_modules for other projects too. But I don't recommend using same node_modules folder for all projects personally as this might mess the entire project. Check out my article about dependency management in JS apps

copy npm global installed package to local

If I have a npm package installed globally, and I want to install the same package locally in some project, does npm download the package again or copy it from the global install folder? If not, is there a way to make it do that?
It is not recommended to copy files from global to local. It is pretty normal to have package installed in both places.
Global package in most of the cases is used in terminal.
Local package is used in application itself.
Also you can use npm link to symlink a global package
Install it in both places. Seriously, are you that short on disk
space? It’s fine, really. They’re tiny JavaScript programs.
Install it
globally, and then npm link coffee-script or npm link express (if
you’re on a platform that supports symbolic links.) Then you only need
to update the global copy to update all the symlinks as well.
The first option is the best in my opinion. Simple, clear, explicit. The
second is really handy if you are going to re-use the same library in
a bunch of different projects. (More on npm link in a future
installment.)

Confused in starting a project in node.js with npm install

Hello I am just a noob and still learning. I have already downloaded and tried the chat tutorial of get-started part from socket.io. Now, I am again learning from another source. What's confusing me is that, do I always have to npm install in the beginning of every project after writing the dependencies in the package.json? Or is there any other way? I would be very glad if you could help me understand my confusion. Thank you!
Yes, before running, all dependencies must be installed. So you must run npm install.
When developing, you can use npm install --save <package_name> to install a dependency and automatically add it to package.json.
NPM means Node Package Manager. It is used to manage your dependencies to other node modules dynamically thanks to a configuration file called package.json. This way you can easily define the exact versions you need or a mask in order to always retrieve the stable ones for instance.
The command npm install allows to interpret your configuration file and then download the good versions (and this recursively).

Resources