Aspnetcore-angular-universal: Cannot find main-server.ts

Created on 29 Apr 2017  路  8Comments  路  Source: TrilonIO/aspnetcore-angular-universal

Hello the file main-server.ts is missing in the client folder.
The project is binded to a node.js version 5. I have version 7.
Are we supposed to work with that? :) More seriously. Can somebody help me?

FAQ

Most helpful comment

This happened to me too, and I found a way to fix it. Btw, I use Visual Studio 2017.
I tried the method that @AndeyR suggest. And no, re-opening the solution doesn't help no matter how many times i did it.

Here is what I did:

  1. Close Visual Studio.
  2. Delete the "npm_modules" folder.
  3. Open cmd and cd into the project folder.
  4. Run these commands:
    1)npm install
    2)npm run build:dev
    3)dotnet restore
  5. Open the .csproj and press F5.

Holla!! It works.
Hope this help.
Appreciate if @MarkPieszak can help explain why is this happening?

All 8 comments

Its happened to me too with fresh cloned repository.
Though main-server.ts is there even if it shows that error. And error fixes itself after 2 solutions reopenings.

So visual studio throws the error but then eventually it goes away?
It seems VS doesn't have the best Typescript support out of the gate, compared to something like VSCode.

One thing to make sure: Make sure VS is using the latest version from your PATH not the one that came inside VS.

https://i1.wp.com/ryanhayes.net/wp-content/uploads/2015/07/Capture.png?zoom=2&resize=628%2C365

Make sure $(PATH) is at the top.nthis helps with multiple random things.

You can use any Node above 5, 7 is totally fine!

So visual studio throws the error but then eventually it goes away?

At least it was like that for me, and I tested it an hour ago. Its up to @marcelluswalace to confirm or deny whether it worked for him.

This happened to me too, and I found a way to fix it. Btw, I use Visual Studio 2017.
I tried the method that @AndeyR suggest. And no, re-opening the solution doesn't help no matter how many times i did it.

Here is what I did:

  1. Close Visual Studio.
  2. Delete the "npm_modules" folder.
  3. Open cmd and cd into the project folder.
  4. Run these commands:
    1)npm install
    2)npm run build:dev
    3)dotnet restore
  5. Open the .csproj and press F5.

Holla!! It works.
Hope this help.
Appreciate if @MarkPieszak can help explain why is this happening?

So it's because Visual Studio comes with an old version of Node and NPM (no idea why it's packaged that way), if you look at the above comment and Go to Options -> projects and solutions -> external web tools, you can make sure your $(PATH) takes precedence over the VS installation, then once you delete node_modules and reopen VS, it'll install it with npm 3+ and the newer version of Node. Make sure you have Node 6 or higher installed on your machine.

Npm 2 or lower has hierarchy installation problems which is why projects error out with it. That's what comes with VS by default. Quite strange right 馃檲

When you installed via command line it was using your Path node installation which had the correct npm 3+, that's why it ended up working.

This is similar to this issue: https://github.com/MarkPieszak/aspnetcore-angular2-universal/issues/166

Even if you have VS set up correctly, you also need to run the npm run build:dev or the dist folder isn't created. It is not ran automatically for VS.

I'll make sure to add that in the Readme, thank you guys!

Added notes in Readme to make sure npm run build:dev is ran if things don't work properly out of the box from Visual Studio.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

borgotecnologia picture borgotecnologia  路  15Comments

MarkPieszak picture MarkPieszak  路  30Comments

consigliory picture consigliory  路  29Comments

MaklaCof picture MaklaCof  路  21Comments

consigliory picture consigliory  路  17Comments