1

When I use Yarn in an ASP.NET Core 2.1 Web Application to add a package, e.g., jquery-autocomplete, it removes the existing packages already installed. Why is it doing that? Does it have something to do with Popper.js, which seems to be a dependency of the package I want to install when this happens?

At the command prompt in the project root I typed:

yarn add --modules-folder=wwwroot\lib autocomplete
tk421
  • 5,775
  • 6
  • 23
  • 34
Momenee
  • 31
  • 4
  • Correction: at the command prompt I entered yarn add --modules-folder=wwwroot\lib jquery-autocomplete – Momenee Nov 12 '18 at 16:01
  • What do you mean with "removes existing packages"? Does it remove them from your package.json or does it remove files in lib folder? – Christoph Lütjen Nov 12 '18 at 20:26
  • It removes all files from the lib folder. – Momenee Nov 13 '18 at 16:18
  • Also, in the npm folder under Dependencies, the references to the files removed from the lib folder say "not installed,", e.g., bootstrap - not installed – Momenee Nov 13 '18 at 16:45
  • Ok, I fear you have "some setup" that works differently as you think it works. You'll have to do some research. In most cases npm modules are stored in a folder "node_modules" that is outside your wwwroot. Then there's a wwwroot/lib folder with js libs but these are not managed using npm but with bower or LibManager https://www.stevejgordon.co.uk/library-manager-libman-visual-studio-2017 . – Christoph Lütjen Nov 13 '18 at 17:41
  • Thanks for the link, I will check out Library Manager. My understanding from this link, https://stackoverflow.com/questions/44844048/moving-away-from-bower-discontinued-to-use-yarn-npm-instead-net-core-mvc-vs, was that yarn/npm was in, bower out. Now it's LibMan? This constant state of flux with the code makes it hard to get any work done. Too many options, dribs and drabs of documentation, permanent state of Open Source chaos. – Momenee Nov 15 '18 at 03:24
  • Your understanding is correct, but npm/yarn work differently and in most cases it requires some additional build setup (gulp/grunt/webpack). LibMan is a lightweight alternative for smaller projects and I think it better fits your requirements. – Christoph Lütjen Nov 15 '18 at 13:34
  • I appreciate your comments, but I would still like to know why using yarn to add a javaScript module removes existing files from the lib folder. – Momenee Nov 16 '18 at 21:50
  • Where's you package.json placed and how does it look bevor and after you added the lib? Which folders are in your wwwroot/lib folder before and after? – Christoph Lütjen Nov 18 '18 at 14:31
  • The package.json file is located under the project directory, same level as appsettings.json, Start.cs, and Program.js. When I use yarn to add a module, it appears as a line in package.json, otherwise the file is unchanged (the already existing files remain listed there). But again, the problem I am trying to understand is why the existing modules are completely removed from the lib folder but seem to be cached by npm somewhere. In ay case, the program is not able to find them. – Momenee Nov 20 '18 at 02:55
  • I guess it's because npm/yarn has absolutely nothing to do with your lib folder. I think your existing lib folder content does not match the files in your package.json (because npm was not used to install them), right? Npm install is not a "copy this package to this location". Please read a little about npm, e.g. https://www.sitepoint.com/beginners-guide-node-package-manager/ – Christoph Lütjen Nov 20 '18 at 19:52
  • Ok, I see, you're following the instructions in the linked question. 1) imho: don't. Reason: Many packages are not made to be placed in public. 2) Manage all packages in your lib folder with yarn or none - that should fix your problem. – Christoph Lütjen Nov 20 '18 at 19:59

0 Answers0