0

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?

LegoLiam
  • 97
  • 3
  • 11
  • When you say "I would like to install this package: npm install lightgallery lg-thumbnail etc etc" it sounds like you are unaware that that is installing several (9) packages each separated by a space. – user3425506 Jun 17 '19 at 11:31
  • I know, the main package is lightgallery the others are plugins – LegoLiam Jun 17 '19 at 11:34
  • Possible duplicate of [How to npm install to a specified directory?](https://stackoverflow.com/questions/14469515/how-to-npm-install-to-a-specified-directory) – ferminx360 Jun 17 '19 at 11:36
  • it is not duplicated because I ask how to use it even if it is installed on the main node, read the comment to your answer ... I also modify the question to make it more specific – LegoLiam Jun 17 '19 at 11:41

1 Answers1

0

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

ferminx360
  • 95
  • 8
  • Ok so I keep them installed in the root node_modules, but to use them then, what is your advice? recompile everything with the webpack mix? – LegoLiam Jun 17 '19 at 11:37
  • I'm not a gurú of JS, but if you have a React, or React Native project, Hot Reloading is an option. To use that modules, you will have to import them, and the method that you can use depends on framework. – ferminx360 Jun 17 '19 at 15:37