I'm trying to create a WebDeploy package to handoff to my system admins for the netcore2.0 angular 4 project. but I keep getting the following error when I run the Publish command on the project in VS 2017...
The command "node node_modules/webpack/bin/webpack.js --env.prod" exited with code 2.
Attached in the error log from npm-cache...
2017-10-09T14_36_28_220Z-debug.log
It is basically not looking in the correct directory for the package.json file...
This command works...
node node_modules/webpack/bin/webpack.js --config webpack.config.vendor.js --env.prod
This command does not:
node node_modules/webpack/bin/webpack.js --env.prod
Any thoughts?
I might be off the mark here but I found your question while trying to fix the same error message I got after starting up the ReactRedux template. I also found this post, https://stackoverflow.com/questions/45764501/angular-dot-net-core-2-0-build-issue, so I went along and found that Visual Studio, Tools -> Options -> Projects and Solutions -> Web Package management -> External Web Tools has my path as a path. And that in my path variable I had two paths to nodejs, the actual one 'c:\program files\nodejs\' and an old empty one 'c:\program files (x86)\nodejs\'. I removed the old stinky path and bing.
I only have the $(PATH) variable itself... No other references to node...the system path only has 1 node reference...
Added piece of info... I think that it has something to do with TFVC and how it branches... I have recreated the app from scratch and used git instead and it builds the deploy package for me. I noticed in the log it was looking in the wrong folder for the package.json file... It wasnt looking down into the branch folder for it. I thought I would be better off just using Git than trying to figure out the TFVC issue...let me know if you guys want to explore this further and I can try to help on the side... Just didn't have time this week...projects need to get done.
When you run webpack, you need to be sure that its current working directory is the root directory of your project (the directory containing package.json). That's the only thing I can think that might be causing it to look in the wrong place for package.json.
If you investigate further and believe there's a problem in any of the code in this repo, please let us know the details!
Still trying to fix this problem. I get this problem while deploying my app to Azure through VSTS. In local it runs fine however in VSTS build it gives me this problem:
Module not found : error : Can't resolve './../$$_gendir/ClientApp/app/app.module.server.ngfactory' in 'd:\a\1\s\ClientApp' [d:\a\1\s\MenuRushWeb.csproj]
@ ./ClientApp/boot.server.ts 7:0-94
EXEC : ERROR in error : Cannot determine the module for class UserDetailComponent in d:/a/1/s/ClientApp/app/components/aa-todelete-appseed/user-detail/user-detail.component.ts! Add UserDetailComponent to the NgModule to fix it. [d:\a\1\s\MenuRushWeb.csproj]
Cannot determine the module for class ControlMessages in d:/a/1/s/ClientApp/app/components/control-messages/control-message.component.ts! Add ControlMessages to the NgModule to fix it.
Cannot determine the module for class UserBasicInfoInputComponent in d:/a/1/s/ClientApp/app/components/user-basicinfo-input/user-basicinfo-input.component.ts! Add UserBasicInfoInputComponent to the NgModule to fix it.
Cannot determine the module for class UserPhoneInputComponent in d:/a/1/s/ClientApp/app/components/user-phone-input/user-phone-input.component.ts! Add UserPhoneInputComponent to the NgModule to fix it.
Cannot determine the module for class CounterComponent in d:/a/1/s/ClientApp/app/containers/aa-todelete-appseed/counter/counter.component.ts! Add CounterComponent to the NgModule to fix it.
Cannot determine the module for class NgxBootstrapComponent in d:/a/1/s/ClientApp/app/containers/aa-todelete-appseed/ngx-bootstrap-demo/ngx-bootstrap.component.ts! Add NgxBootstrapComponent to the NgModule to fix it.
Cannot determine the module for class UsersComponent in d:/a/1/s/ClientApp/app/containers/users/users.component.ts! Add UsersComponent to the NgModule to fix it.
at Error (native)
at syntaxError (d:\a\1\s\node_modules\@angular\compiler\@angular\compiler.es5.js:1699:2)
at analyzeAndValidateNgModules (d:\a\1\s\node_modules\@angular\compiler\bundles\compiler.umd.js:24166:15)
at AotCompiler.analyzeModulesAsync (d:\a\1\s\node_modules\@angular\compiler\bundles\compiler.umd.js:23797:46)
at CodeGenerator.codegen (d:\a\1\s\packages\compiler-cli\src\codegen.ts:41:10)
at Function.NgTools_InternalApi_NG_2.codeGen (d:\a\1\s\packages\compiler-cli\src\ngtools_api.ts:112:26)
at _donePromise.Promise.resolve.then (d:\a\1\s\node_modules\@ngtools\webpack\src\plugin.js:430:58)
at process._tickCallback (internal/process/next_tick.js:103:7)
at Module.runMain (module.js:606:11)
at run (bootstrap_node.js:394:7)
at startup (bootstrap_node.js:149:9)
at bootstrap_node.js:509:3
d:\a\1\s\MenuRushWeb.csproj(73,5): error MSB3073: The command "node node_modules/webpack/bin/webpack.js --env.prod" exited with code 2.
Error: C:\Program Files\dotnet\dotnet.exe failed with return code: 1
Any help is appreciated
@suhaibqaiser This is an Angular usage question - some aspect of your application is not configured correctly for Angular's ahead-of-time (AoT) compilation. It's not specifically to do with publishing to Azure or VSTS. Please see Angular docs or check with the Angular community how to track down what's wrong.
I have same problem that happens when I try to publish to a folder. It runs find.. But something happened along then way that messed up publishing. Ive looked for hours for a fix.. So I guess Ill try doing the project again and separate the angular web site from the server
I know this is a bit of a hack but here is what i did just to get it working real quick to do some live testing
in your .csproj there is likely a build event named "PublishRunWebpack"
it will execute the webpack config and webpack.config.vendor.js
if you have not configured --env.prod correctly (which you likely haven't because its a pain) you can simply remove the --env.prod from the command.
this will execute the configs the same way they are executed locally
if you are having success with your application locally this shouldn't throw an error.
I successfully published after making this change but obviously ill be configuring --prod here soon and I suggest everyone else do the same lol
I started a new asp.net/angular project and got this error, running npm install did the trick.
@AESTechnology it's work for me.
@AESTechnology it's work for me.
This error occurred in my code as well. The fix for me was that the path for app.shared.module.ts file in my webpack.config.js file was incorrect. Corrected the path and error gone.
Most helpful comment
I know this is a bit of a hack but here is what i did just to get it working real quick to do some live testing
in your .csproj there is likely a build event named "PublishRunWebpack"
it will execute the webpack config and webpack.config.vendor.js
if you have not configured --env.prod correctly (which you likely haven't because its a pain) you can simply remove the --env.prod from the command.
this will execute the configs the same way they are executed locally
if you are having success with your application locally this shouldn't throw an error.
I successfully published after making this change but obviously ill be configuring --prod here soon and I suggest everyone else do the same lol