mirror of
https://github.com/aspnet/JavaScriptServices.git
synced 2025-12-22 09:37:45 +00:00
Unhandled Exception: System.AggregateException: One or more errors occurred. (Webpack dev middleware failed because of an error while loading 'aspnet-webpack'. Error was: Error: Cannot find module 'aspnet-webpack' #106
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @Eilon on 4/4/2018
From @mwonger on October 27, 2017 1:40
Using the ASP.NET Core Web Application (ASP.NET Core 2.0) React.js and Redux project template as a baseline
dotnet build -c Debug -o ./app
dotnet publish -c Debug -o ./app
cd app
set ASPNETCORE_ENVIRONMENT=Development
dotnet WebApplication1.dll
Results in the error
error while loading 'aspnet-webpack'. Error was: Error: Cannot find module 'aspnet-webpack'
Tried working around the issue via npm update (npm-shrinkwrap.json present in my directory)
The node_modules folder is created on the publish of the webapplication.csproj
We also got the error
webpack.config.vendor.js not found.
We thought all this stuff would be packaged up via the msbuild lines in the csproj file targets
and
that run npm install node node_modules/webpack/bin/webpack.js --config webpack.config.vendor.js etc.
but it looks like webpack wants to rebuild on the published bits in the app directory when we actually try to start the site up.
dotnet publish looks like it copies the resulting bits from wwwroot\dist*; ClientApp\dist*" Are there other files that need to be copied?
The only workarounds we have found:
instead of doing a build/publish above we do a dotnet run in the project directory (so instead of copying the published bits to a server, we copy the project directory structure including the csproj file)
This effectively starts the web server up on our deployed server using the development hosting environment
Using launch settings from C:\app\WebApplication1\webapplication1\Properties\launchSettings.json...
info: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[0]
User profile is available. Using 'C:\Users\ContainerAdministrator\AppData\Local\ASP.NET\DataProtection-Keys' as key repository and Windows DPAPI to encrypt keys at rest.
info: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[58]
Creating key {9ae79442-a514-42c2-92da-6d5dcb48efb0} with creation date 2017-10-27 01:04:45Z, activation date 2017-10-27 01:04:45Z, and expiration date 2018-01-25 01:04:45Z.
info: Microsoft.AspNetCore.DataProtection.Repositories.FileSystemXmlRepository[39]
Writing data to file 'C:\Users\ContainerAdministrator\AppData\Local\ASP.NET\DataProtection-Keys\key-9ae79442-a514-42c2-92da-6d5dcb48efb0.xml'.
Hosting environment: Development
Content root path: C:\app\WebApplication1\webapplication1
don't use ASPNETCORE_ENVIRONMENT=Development on the server we are deploying to.
is there a way to use the published folder with ASPNETCORE_ENVIRONMENT=Development?
Copied from original issue: aspnet/Home#2258