0

I have created a .Net Core MVC app. At the top level of the project I have my wwwroot directory, my program.cs and startup.cs files as you'd expect. Under Dependencies I have a bower folder with all my bower references (all before introducing angular 2).

When I installed NPM it created a hidden folder 'node_modules' at the root level of the project and then subsequently another folder in Dependencies called npm for all my npm installs. This all seems ok project builds etc. Now I introduce an app folder under wwwroot and I place main.ts, module.ts etc. still all ok. I come back to one of my _Layout.cshtml pages and try to make a reference to some of the js files sitting in the hidden node_modules folder. However, when trying to set the source it always expects these files to be in WWWRoot, but they are up 1 level. A typical reference is:

<script src="node_modules/zone.js/dist/zone.js"></script>

if I move the hidden folder to be under WWWRoot then everything in the npm folder under dependencies says that the dependencies are not installed. Move the hidden folder back to the root level and my dependencies all come back. How can I force the script block to not expect the above to be under wwwroot?

enter image description here

bilpor
  • 3,467
  • 6
  • 32
  • 77
  • If you add a `/` before `node_modules`? – Vassilis Pits Nov 18 '16 at 15:51
  • @VassilisPits Yes, I tried that it still thinks it should be starting at wwwroot – bilpor Nov 18 '16 at 15:52
  • I'm having difficulties understanding your setup (maybe it;s just me). Could you add a diagram with the folders tree and tell me what server do you use? – Vassilis Pits Nov 18 '16 at 15:53
  • @VassilisPits I've added a screen shot this should make it easier to see the structure. You can also see the references that I'm trying to make – bilpor Nov 18 '16 at 16:00
  • Ok where is your `index.html`? – Vassilis Pits Nov 18 '16 at 16:01
  • Also move the scripts to the footer before `

    `

    – Vassilis Pits Nov 18 '16 at 16:02
  • @VassilisPits my start page is a cshtml page and it's in the Views folder. it's not called index but Home.cshtml. The reference above is in an _layout.cshtml page for an area. I dont need Angular for all areas of the app. – bilpor Nov 18 '16 at 16:05
  • Ok I got it, so the `Views` folder is your root `http` folder or the wwwRoot? – Vassilis Pits Nov 18 '16 at 16:06
  • @VassilisPits yes this is where it starts. it essentially re-directs to an accounts area where the user has restricted access until they login. then once logged in depending on their access they are directed to another area of the system. Each area has an _Layout page which is essentially a master page so in each of these they will have different references depending on the requirements for that area. – bilpor Nov 18 '16 at 16:09
  • Well then I guess `node_modules` should be in the same level with your html entry file. Your structure is quite strange for me but I'm not familiar with Azure env and I'm not sure if that affect it. – Vassilis Pits Nov 18 '16 at 16:10
  • 2
    Possible duplicate of [How to access node\_modules folder from wwwroot in asp.net vnext project](http://stackoverflow.com/questions/35527001/how-to-access-node-modules-folder-from-wwwroot-in-asp-net-vnext-project) – Tseng Nov 18 '16 at 16:28

0 Answers0