D
D
Drovosek012019-05-17 19:41:55
npm
Drovosek01, 2019-05-17 19:41:55

How is the search for packages on the computer going?

Hello I am new to using nodejs and npm.
If I am in the terminal in the project folder my_folder which already uses node packages.
If I run the command npm install needed_package -g, then the package will be installed globally, i.e. not to the project folder, but to the C:\Program Files\nodejs\node_modules\ folder.
If I run the command npm install needed_package, the package will be installed in the node_mpdules folder, which is located in the project folder, the path to which is open in the terminal.
If I execute the command npm install needed_package --saveabout the package will be installed in the node_mpdules folder, which is located in the project folder, the path to which is open in the terminal and an entry about the installed package will be added to package.json in "dependencies".
Questions:
1. If a package is only installed globally, when using it in a project, will it be downloaded to the project folder or will it constantly go to C:\Program Files\nodejs\node_modules\ when using that package? And will this add a package entry to package.json?
2. What is the difference between installing locally with and without the --save argument? If the package is installed locally and without --save, then the package files can simply be accessed via the direct path, but there will be no entry in package.json about this package, and when the project is transferred (with the npm install command), everything will break, i.e. to. there will be no package, unlike when we installed it with --save? Then what's the point of installing the package without --save?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question