I have a Web Application hosted in Azure.
It's configured to automatically build and deploy from the GitHub repository.
I was using a version of angular.min.js which I had installed from a nuget package, and then directly checked in. Now I want to change this, and incorporate javascript packages from npm instead of nuget.
I did the following:
- Added an npm configuration file
- Add the dependency "angular": "^1.6.5"
Here's the complete package.json file:
{
"version": "1.0.0",
"name: "asp.net",
"private": true,
"dependencies": {
"angular": "^1.6.5"
},
"devDependencies": {}
}
Then, in my razor page, I referenced angular directly from the node_modules folder:
<script type="text/javascript" src="~/node_modules/angular/angular.min.js"></script>
This worked on my local machine.
I checked this into Github, and the Azure framework built and deployed my code. However, the folder node_modules is not present under D:\home\site\wwwroot
I tried added a pre-build step:
npm install
but this did not solve the problem.
Using kudu, I bought up the debug console on the web server. I set the location to the folder D:\home\site\wwwroot, then typed npm install. This worked: it created and populated the node_modules folder, and my website could now access the angular file.
So, either the build is not restoring the packages, or it is restoring the packages but not deploying them to the wwwroot folder.
Is there a correct way to include javascript files from node packages in ASP.NET MVC apps on Azure?