aspnet / JavaScriptServices

[Archived] This repository has been archived
Apache License 2.0
3.04k stars 521 forks source link

NodeInvocationException: Prerendering failed because of error: Error: Cannot find module at webpackMissingModule #1248

Closed yeganehaym closed 7 years ago

yeganehaym commented 7 years ago

i faced to this error, each refer or link i have this error spring up i put some images in 'wwwroot/img' and i set address './img/12.jpg'

NodeInvocationException: Prerendering failed because of error: Error: Cannot find module "./img/12.jpg" at webpackMissingModule (D:\projects\Core\Bwin\ClientApp\dist\main-server.js:19005:87942) at Object.<anonymous> (D:\projects\Core\Bwin\ClientApp\dist\main-server.js:19005:88046) at __webpack_require__ (D:\projects\Core\Bwin\ClientApp\dist\main-server.js:20:30) at Object.<anonymous> (D:\projects\Core\Bwin\ClientApp\dist\main-server.js:19057:22) at __webpack_require__ (D:\projects\Core\Bwin\ClientApp\dist\main-server.js:20:30) at D:\projects\Core\Bwin\ClientApp\dist\main-server.js:10401:47 at Object.<anonymous> (D:\projects\Core\Bwin\ClientApp\dist\main-server.js:10405:2) at __webpack_require__ (D:\projects\Core\Bwin\ClientApp\dist\main-server.js:20:30) at Object.<anonymous> (D:\projects\Core\Bwin\ClientApp\dist\main-server.js:16131:88) at __webpack_require__ (D:\projects\Core\Bwin\ClientApp\dist\main-server.js:20:30) Current directory is: D:\projects\Core\Bwin Microsoft.AspNetCore.NodeServices.HostingModels.HttpNodeInstance+<InvokeExportAsync>d__7.MoveNext()

NodeInvocationException: Prerendering failed because of error: Error: Cannot find module "./fonts/flexslider-icon.eot" at webpackMissingModule (D:\projects\Core\Bwin\ClientApp\dist\main-server.js:19005:87942) at Object.<anonymous> (D:\projects\Core\Bwin\ClientApp\dist\main-server.js:19005:88046) at __webpack_require__ (D:\projects\Core\Bwin\ClientApp\dist\main-server.js:20:30) at Object.<anonymous> (D:\projects\Core\Bwin\ClientApp\dist\main-server.js:19057:22) at __webpack_require__ (D:\projects\Core\Bwin\ClientApp\dist\main-server.js:20:30) at D:\projects\Core\Bwin\ClientApp\dist\main-server.js:10401:47 at Object.<anonymous> (D:\projects\Core\Bwin\ClientApp\dist\main-server.js:10405:2) at __webpack_require__ (D:\projects\Core\Bwin\ClientApp\dist\main-server.js:20:30) at Object.<anonymous> (D:\projects\Core\Bwin\ClientApp\dist\main-server.js:16131:88) at __webpack_require__ (D:\projects\Core\Bwin\ClientApp\dist\main-server.js:20:30) Current directory is: D:\projects\Core\Bwin

mpalmer-sps commented 7 years ago

hello @yeganehaym , I think your pathing might be wrong. I also got that error at one point in time with the project I have started here: https://github.com/mpalmer-sps/PluralSightNg2Fundamentals In my project where I use images (the events.service.ts file) I use the following for image paths that are placed in the wwwroot/images/events: imageUrl: '/images/events/angularconnect-shield.png',

Try that in your path and it may work...

-- Martin

SteveSandersonMS commented 7 years ago

@yeganehaym If you have any repro steps I'd be happy to take a look. Otherwise hopefully @mpalmer-sps's suggestion might help!

yeganehaym commented 7 years ago

i used my picture in html file not ts file even vs 2017 helped me to set url microsoft has a tutorial video to launch angular project and i compared to it and are the same but im still stranded here

yeganehaym commented 7 years ago

i transfered it from gitlab to github https://github.com/yeganehaym/P2B

i added some css files too and they have this error too i mean the picture and font are defined in css if i put url in address bar and press enter, browser show me the picture

SteveSandersonMS commented 7 years ago

I think @mpalmer-sps is correct. Your image URLs are not correct. Unless they start with /, the html-loader will try to bundle them. So typically there are two ways to reference images:

even vs 2017 helped me to set url

VS doesn't know about your Webpack config so don't rely on that.

yeganehaym commented 7 years ago

yeah you'r right, when i put images in same directory , they are working

salmanlone commented 6 years ago

@SteveSandersonMS your 2nd point also worked for me. just need to put / before the url. Thanks a lot!