reproduce:
mkdir temp
cd temp
dotnet new angular
yarn install # (or cnpm install) npm is very slow in China
vim temp.csproj # change npm to yarn or cnpm
dotnet restore
dotnet run # everything works well
dotnet publish
here is the log:
Microsoft (R) Build Engine version 15.3.409.57025 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.
temp -> /home/zeeko/Projects/temp/bin/Debug/netcoreapp2.0/temp.dll
✔ Installed 51 packages
✔ Linked 0 latest versions
✔ Run 0 scripts
✔ All packages installed (used 18ms, speed 0B/s, json 0(0B), tarball 0B)
Hash: 6519e31713523a1b78e0b5e515cf7d3dc8dab468
Version: webpack 2.5.1
Child
Hash: 6519e31713523a1b78e0
Time: 7823ms
Asset Size Chunks Chunk Names
89889688147bd7575d6327160d64e760.svg 109 kB [emitted]
vendor.js 194 kB 0 [emitted] vendor
vendor.css 289 kB 0 [emitted] [big] vendor
Child
Hash: b5e515cf7d3dc8dab468
Time: 7811ms
Asset Size Chunks Chunk Names
89889688147bd7575d6327160d64e760.svg 109 kB [emitted]
vendor.js 3.4 MB 0 [emitted] [big] vendor
Hash: 2957d49fe26751c2264e8140e9bae979f059541c
Version: webpack 2.5.1
Child
Hash: 2957d49fe26751c2264e
Time: 6651ms
Asset Size Chunks Chunk Names
main-client.js 268 kB 0 [emitted] [big] main-client
ERROR in ./ClientApp/boot.browser.ts
Module not found : error : Can't resolve './../$$_gendir/ClientApp/app/app.module.browser.ngfactory' in '/home/zeeko/Projects/temp/ClientApp' [/home/zeeko/Projects/temp/temp.csproj]
@ ./ClientApp/boot.browser.ts 5:0-95
Child
Hash: 8140e9bae979f059541c
Time: 6859ms
Asset Size Chunks Chunk Names
main-server.js 1.8 MB 0 [emitted] [big] main-server
ERROR in ./ClientApp/boot.server.ts
Module not found : error : Can't resolve './../$$_gendir/ClientApp/app/app.module.server.ngfactory' in '/home/zeeko/Projects/temp/ClientApp' [/home/zeeko/Projects/temp/temp.csproj]
@ ./ClientApp/boot.server.ts 8:0-94
/home/zeeko/Projects/temp/temp.csproj(41,5): error MSB3073: The command "node node_modules/webpack/bin/webpack.js --env.prod" exited with code 2.
version info:
dotnet sdk: 2.0.0
nodejs:8.5.0
yarn:1.0.4
cnpm:5.1.1
system: both Windows 10 Insider Fall Update Preview and Manjora 17.0.5
May be related to this issue that happens in AoT production builds.
https://github.com/aspnet/JavaScriptServices/issues/1293
From the thumbs-up, it looks like maybe @davidsekar's comment provides a resolution.
Failing that, your repro sounds like you have a scenario that works fine with NPM, but fails with cnpm? Is that really the case? If so, cnpm must not be an adequate drop-in replacement for NPM. Likewise Yarn is not really to be trusted because it doesn't support npm-shrinkwrap.json files so there's no guarantee it will give you a compatible set of packages (if you really want to use Yarn, you will need to create a yarn.lock file referencing the same package resolutions as are in npm-shrinkwrap.json to ensure your dependencies are correct).
For me npm install [email protected] did solve the problem.