npm "install" location in Visual Studio; .Net Core app - visual-studio-2017

I'm just starting to play with my first .Net Core applications and am trying to use npm for client-side libraries. They get added to node_modules but aren't "installed" to wwwroot.
My question appears to have been asked before without answers:
How do I include libraries that installed via NPM to my MVC project on Visual Studio 2017
I've tried to install cropperjs. That works insofar that the files are downloaded and added to the node_modules folder:
projectfolder
node_modules
cropperjs
dist
src
package.json, changelog, readme, license etc. files
Now how would I get these files into my wwwroot directory to use them? The documentation is slightly confusing I'm afraid.
Thanks for enlightening me!

Sorry, found the answers after seeing the list of "related questions" to my own.
apparently, it is indeed required to copy the required files and folders over to the wwwroot location.
These two questions yielded answers and comments that solve my question:
How to access node_modules folder from wwwroot in asp.net vnext project
How to use npm with ASP.NET Core

Related

Files Not Appearing In Solution Explorer

I am using Visual Studio 2017. I created an empty ASP.NET Core Web Application, and then installed the nuget package for Bootstrap through the Nuget Package Manager Console and the bootstrap .css and .js files aren't showing up in the solution explorer. Is this a bug or is there more to using nuget?
the bootstrap .css and .js files aren't showing up in the solution explorer. Is this a bug or is there more to using nuget?
That because the usage of NuGet for css/javascript libraries is discouraged. You should use the npm (Node Package Manager) to add the JavaScript libraries instead of using NuGet. The newer project file formats, PackageReferences, only supports files that are in a contentFiles directory inside the NuGet package.
To use the package Bootstrap to the .net core project, you need to select your ASP.NET Core Web Application and add a new file to the project root. While in the template manager (Add->New Item...), search for "npm Configuration file":
Then edit the file and add your dependency, i.e.
package.json (npm) or bower.json:
"dependencies": {
"Bootstrap": "4.1.3"
}
Note: Once you save, the file will be downloaded in a directory named "node_modules`. This alone won't be enough, as the required files need to be copied over to wwwroot folder, where they can be accessed when the application runs.
For the detailed info, see NPM, BOWER, NUGET, GULP – The Four Horsemen of ASP.NET CORE Apps and ASP.NET Core 2.0 and the End of Bower.
Hope this helps.
Content in the NuGet file that gets put into your project is only supported with packages.config, which is not supported in .NET Core. PackageReferences do not support getting content from the package.
I'm not 100% sure, but I think the ASP.NET team's recommendation is to use the preferred distribution method of the content you want to use. I haven't kept up with web development trends, but a few years ago web content like bootstrap were distributed with npm, so that's my recommendation for you. Creating a new Angular JS app with Microsoft's new web app template includes a npm package.json, so I think using npm is a safe bet.

Server can't find packages after upgrade

Private nuget server can't find packages after upgrade
I had to update the nuget server to get it to accept packages that were failing to upload (apparently the package format changed in dotnet core or something). Now all the previously uploaded packages aren't showing up in nuget. I can see all of them on the server just sitting there in their directories. But they can't be found. New packages are ending up in the server's package directory rather than their own directories.
From prior experience I don't think just copying the packages into the packages directory is going to work.
Trying to actually upgrade the NuGet.Server package from v2.8.6 to v3.0.2 appears to work but in the end the package is still at v2.8.6.
Don't try to upgrade nuget.server projects. That way lies madness.
Carry out the instructions like making a new one.
1) Create a new empty Web Project; target framework is NET Framework 4.6
2) Add NuGet.Server version 3.0.2
3) Fix duplicate <compilation> tag in web.config
4) Apply your API key to web.config and any other nuget configurations you have.
5) Remove old project from installation directory; leaving behind only the Packages directory and optionally any static files you uploaded to the installation directory itself (I keep a copy of nuget.exe and local project icons there).
6) Copy build output of new project to web installation directory.
It starts working. I don't know what's up with upgrading but it ends up with a smashed web.config and who knows what else.

Cannot add jquery using NuGet Package Manager in VS 2017

I tried to add jquery to an asp.net core project using NuGet Package Manager of Visual Studio Community 2017 (version 15.5.2), but there is no jquery js files added to my project. Here is the screenshot:
Tried with Bower Package Manager, then the files are downloaded to bower_components folder but not to wwwroot as many people said.
Same thing for jquery-ui, bootstrap, etc.
Anyone experienced the same problem. Is there any work-around?
BTW, this accepted solution doesn't work for me: Where are jQuery-UI scripts stored in MVC6 project?
For ASP.NET Core in Visual Studio 2017:
NuGet shouldn't be used for client-side libraries.
After that Bower was used for this purpose, but now it is deprecated.
Currently the supported tool for managing client-side libraries is LibMan. Here is very good explanation how to use it in VS2017.

Nuget restore for some team members does not work - Microsoft.AspNet.Mvc and other core packages

I'm using Visual Studio 2015 community along with some other in our team. A mvc web application that I created works fine on my machine but when others get it to build, all packages download successfully but some of the core MVC such as Microsoft.AspNet.Mvc, Razor, etc don't install.
What was weird that on their machine, if they went into PM and downgraded the MVC package to 5.2.2 and then upgraded back to 5.2.3 it worked. But now when setting up the build on our build server, we get the same issue!
Any ideas why this bizarre behavior?
Didn't check that but why would that matter? When the Dev downgrades the version on 1 package and then upgrades back everything is as it should be
EDIT (4th Oct 2016) after investigating a bunch of things:
One of the developers at one point committed the "Packages" folder which sits at the root which had the "Microsoft.AspNet.Mvc" and other folders but without the dlls. This made the "Restore packages" not really "Restore" these as the folder already existed but when the build was run the artifacts weren't actually there in the folder to be moved into bin.
I deleted the packages folder, added it to gitignore and committed the change which made everything 'green'!

NPM repo missing file

I have a git repo for an Ember Addon:
https://github.com/lifegadget/ui-responsive-toolbelt
It passes all unit tests. It has been published to npm as ui-responsive-toolbelt. I have used npm's "link" functionality to test locally that this "addon" (in Ember parlance) works fine in consuming application when included in the package.json file as a dependency.
Surprisingly, and I'm completely flummoxed on this, when npm installs this dependency into an Ember project directory it brings across a vast majority of the files without complaining. From NPM's perspective it appears to be a clean install. Unfortunately an addon depends heavily on it's "entry point" which is the index.js in the root directory of the repo. I have very clearly included this file in the repo but for some reason it is not being brough over!
I have tried this on two computers and three Ember projects and all have the same outcome. Please help!
the error message I get from Ember-CLI when I try to start the server with ember serve is:
The package ui-responsive-toolbelt is not a properly formatted package, we have used a fallback lookup to resolve it at /path/to/project/node_modules/ui-responsive-toolbelt. This is generally caused by an addon not having a main entry point (or index.js).
This message is repeated twice and then I get:
The ui-responsive-toolbelt addon could not be found at /path/to/project/node_modules/ui-list/node_modules/ui-responsive-toolbelt.
I confirmed that your repo looks fine
npm install ui-responsive-toolbelt does not download the index file
So the problem is that npm publish is not working properly. There is a bug filled for that. https://github.com/npm/npm/issues/5082
What you can do is publish again your addon using a recent npm version (or play with older versions) until you see that the index file is added too.