Npm install module provide a lot of files - javascript

When I use the npm install 6 month ago and install module it create new one folder under the node_modules, the folder with all files for this module, but now when I use it create multifile files for one module, how can I install a module to specific folder as before ?
I use webStrorm

Your dependencies will now be installed maximally flat. Insofar as is
possible, all of your dependencies, and their dependencies, and THEIR
dependencies will be installed in your project's node_modules folder
with no nesting.
Yes, in npm 3 your dependencies will be installed maximally flat, so it's all about npm versions.
Try running npm -v to make sure of that.
Here's an article about that.

Related

What's the difference between npm install and manual installation?

So i'm looking at requirejs. I can either install this package with npm install requirejs, or download it manually from the website. What's the difference? Are there tradeoffs to either one? Is npm install just a fancier way of manually installing? Thanks.
imagine you have 10 libraries in package.json, and you want to install all of them at once, you can just do "npm i" and it will take care of all, in just ~10sec. compare this with installing those 10 lib manually, it is indeed a good friend, to help you ease the process of downloading lib for you in no time.
Yes, npm install is just a fancier way to add package that help saving your precious time.
Base on the description here: npm install.
If the package has a package-lock, or an npm shrinkwrap file, or a yarn lock file, the installation of dependencies will be driven by that
Install the dependencies in the local node_modules folder.
In global mode (ie, with -g or --global appended to the command), it installs the current package context (ie, the current working directory) as a global package.
By default, npm install will install all modules listed as dependencies in package.json.
With the --production flag (or when the NODE_ENV environment variable is set to production), npm will not install modules listed in devDependencies. To install all modules listed in both dependencies and devDependencies when NODE_ENV environment variable is set to production, you can use --production=false.
Without a package manager like npm or yarn, it could take you a lot of time just for installing stuff. And while you are developing with node js, you'd have ton of things to install.
Every modern programming language has it's own package manager, so why you ever need to manually install them?

Install npm module from git that does not have package.json at root

I want to install the master branch of https://github.com/NativeScript/nativescript-angular into my JS project.
npm supports this via:
npm i NativeScript/nativescript-angular#master
However, the actual module (and its package.json) is in a nativescript-angular subdirectory. Because of this, the command above fails.
How do I pull this off? Or is it really not supported?

Share npm devDependencies across modules

I have a number of modules that use the same devDependencies and I would like to make those dependencies a module itself, or some other way to manage them centrally. Are there any established patterns for achieving this?
I've looked in to using npm scripts to install the dev dependencies in the parent module, however it does feel a bit hacky e.g.
module-x has a dev dependency on module-shared-dev-dependencies. module-shared-dev-dependencies has a postinstall script that changes the cwd to module-x and npm install --save-dev eslint prettier husky ... etc. It then copies over the relevant config info such as rc files. Modules like husky currently only have the config info in the package.json file itself, so that would need modified too.
There is also the potential to have a base module in the git that all other modules fork from, however, I'd rather stick to an npm module approach if possible.

Install NodeJS packages from file with NPM install

Is it possible to install nodejs packages (/modules) from files like in ruby's Gemfile as done with bundle install or python's requirements file (eg: requirements.pip) as done using pip install -r commands ?
Say I have a file where three or four package names are listed.
How would I instruct npm to install packages whose names are found in that file (and resolve dependencies which it also does)?
Just create your package JSON, you can use yarn to manage your packages instead of npm, it's faster.
Inside your package you can create a section of scripts accessed by npm run
scripts: {
customBuild: 'your sh code/ruby/script whateve'
}
And after you can run on terminal, npm run customBuild for example
you can use NPM init to create a package.json file which will store the node packages your application is dependent on, then use npm install which will install the node packages indicated in the package.json file

Gulp: npm install gulp --save-dev was expecting to see just a gulp folder inside the node_modules folder

Wonder if someone can tell me if im doing something wrong?
Downloaded Node from there website
Installed Gulp globally (npm install --global gulp)
Made a folder and inside ran (npm init) which makes the package.json file
Installed gulp to the project (npm install --save-dev gulp)
This then adds gulp as a dependency inside package.json and creates a node_modules folder.
I was expecting to only see a gulp folder inside node_modules folder like so:
| node_modules
|-- gulp
But for some reason it's adding around 132 extra dependency folders, is this correct, should this happen? I would of thought these should be contained inside the gulp folder itself?
Im using a Mac, Node v5.2.0, NPM v3.3.12, Gulp v3.9.0
npm since v3 puts almost all dependencies to the node_modules directly.
Your dependencies will now be installed maximally flat. Insofar as is possible, all of your dependencies, and their dependencies, and THEIR dependencies will be installed in your project's node_modules folder with no nesting. You'll only see modules nested underneath one another when two (or more) modules have conflicting dependencies.
References:
https://github.com/npm/npm/releases/tag/v3.0.0

Categories