Aspnetcore-angular-universal: Prerendering failed because of error: Cannot find module '..\aspnetcore-angular2-universal\Client\dist\main-server'

Created on 9 Apr 2017  Â·  11Comments  Â·  Source: TrilonIO/aspnetcore-angular-universal

Hi!

Previous error was on the work, there maybe not installed last version vs2017.
And I decide run this project in my own computer. Install latest vs2017 15.1 (26403), npm 4.1.2, node 7.5.0.
Get this error, when running project and go to localhost:5000/. Please, help.
image
image
image

Most helpful comment

If you're running into problems with it when you first run the project in Visual Studio, then you'll need to open a command prompt, nagivate to the project directory then run "npm run build:dev" manually. That should force the first build and generate the main.server file.

After that, the subsequent changes are automatically built when you save any changes to the project files in the Client folder.

All 11 comments

Did you try to npm install and npm run webpack? If there are any errors related to node or webpack you will see them in the console. You can try to run it in VS by F5'ing it as well.

Try running npm run build:dev to build them first

If npm run webpack doesn't work (no webpack installed error), try npm run build:dev -- --verbose. Learned that little trick from Mark in an earlier post.

Are the webpack scripts supposed to run automatically on hitting FT or
should the readme be updated?

On 10 Apr. 2017 8:57 am, "rphilp" notifications@github.com wrote:

If npm run webpack doesn't work (no webpack installed error), try npm run
build:dev -- --verbose. Learned that little trick from Mark in an earlier
post.

—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/MarkPieszak/aspnetcore-angular2-universal/issues/166#issuecomment-292819652,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AF8zNZLSw5z0kbOHL2CYh772gbeP98rPks5ruWJygaJpZM4M4HyF
.

In the past it was run after npm i. Looks like the post install was changed.
Old:

"scripts": {
    "test": "karma start Client/test/karma.conf.js",
    "postinstall": "npm run build:webpack",
    "build:webpack": "npm run webpack-vendor && npm run webpack",
    "webpack": "webpack --progress --color",
    "webpack-vendor": "webpack --config webpack.config.vendor.js --progress --color"
  }

New:

"scripts": {
    "test": "karma start Client/test/karma.conf.js",
    "build:dev": "webpack --progress --color",
    "build:aot": "webpack --env.aot --env.client & webpack --env.aot --env.server"
  }

Short term, add the "postinstall": "npm run build:dev", line in the scripts and npm i should kick off the dev build.

I'll see if I can finally figure out how to submit a PR for that and the IE Shims.

I removed it mainly because of Azure builds (or other cloud / production builds), having a Dev webpack build after just makes things take longer since we want it to build:AoT to get the prod bundles. Otherwise it was great in postinstall, wish postinstall had hooks for dev / prod modes.

Think we should just updated the readme to say install && npm run build:dev for now, you're right.

I execute in cmd "npm run build:dev" and get it.
image

I do how wrote there "npm rebuild node-sass --force" and project is running.
image
Only one fail happened.
image

SASS is a little princess, but this is simple. VS is using Node 5.x internally and you have Node 6.x or 7.x installed. Let VS use the Node Version you have installed. Go to

Tools -> Options -> Projects and Solutions -> Web Package Management

and paste the path of you installation directory in. Make sure that it is on top of $(VSINSTALLDIR)\Web\External. In my case (sorry for my German VS) it is C:\Program Files\Anwendungen\Entwicklung\Node:

bildschirmfoto 2017-04-10 um 21 49 41

Delete the folder node-sass in your node_modules and run npm install again.

So, I can't hit f5 in visual studio and get it to run the build:dev task? The postinstall hint above doesn't seem to kick that off...

If you're running into problems with it when you first run the project in Visual Studio, then you'll need to open a command prompt, nagivate to the project directory then run "npm run build:dev" manually. That should force the first build and generate the main.server file.

After that, the subsequent changes are automatically built when you save any changes to the project files in the Client folder.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

michael-vasyliv picture michael-vasyliv  Â·  4Comments

MapleYe picture MapleYe  Â·  3Comments

rcanpahali picture rcanpahali  Â·  3Comments

johnwpowell picture johnwpowell  Â·  4Comments

digibum picture digibum  Â·  4Comments