damienbod / AngularWebpackVisualStudio

Template for ASP.NET Core, Angular with Webpack and Visual Studio
https://damienbod.com/2016/06/12/asp-net-core-angular2-with-webpack-and-visual-studio/
MIT License
488 stars 128 forks source link

Error: cannot find module './config/webpack.undefined.js #103

Closed tonywr71 closed 7 years ago

tonywr71 commented 7 years ago

I am trying to get this going but running into issues. Trying to run in Visual Studio 2017 Enterprise. From scratch, I built and ran the application (tried both debug and without) and it's failing to start. The error in the Task Runner explorer is D:\AngularWebpackVisualStudio-master\AngularWebpackVisualStudio-master\src\AngularWebpackVisualStudio> cmd /c SET NODE_ENV=development&& webpack --color module.js:471 throw err; ^ Error: Cannot find module './config/webpack.undefined.js' at Function.Module._resolveFilename (module.js:469:15) at Function.Module._load (module.js:417:25) at Module.require (module.js:497:17) at require (internal/module.js:20:19) at module.exports (D:\AngularWebpackVisualStudio-master\AngularWebpackVisualStudio-master\src\AngularWebpackVisualStudio\webpack.config.js:3:10) at handleFunction (D:\AngularWebpackVisualStudio-master\AngularWebpackVisualStudio-master\src\AngularWebpackVisualStudio\node_modules\webpack\lib\prepareOptions.js:26:13) at prepareOptions (D:\AngularWebpackVisualStudio-master\AngularWebpackVisualStudio-master\src\AngularWebpackVisualStudio\node_modules\webpack\lib\prepareOptions.js:11:13) at requireConfig (D:\AngularWebpackVisualStudio-master\AngularWebpackVisualStudio-master\src\AngularWebpackVisualStudio\node_modules\webpack\bin\convert-argv.js:98:14) at D:\AngularWebpackVisualStudio-master\AngularWebpackVisualStudio-master\src\AngularWebpackVisualStudio\node_modules\webpack\bin\convert-argv.js:104:17 at Array.forEach (native) Process terminated with code 1.

Firstly, I've noticed that in the web.config file it contains: /// <binding ProjectOpened='Run - Development' /> which I thought overrode the binding in package.json: "-vs-binding": { "ProjectOpened": [ "watch-webpack-dev" ] }

Secondly, it looks like the env variable isn't being set, so its returning undefined instead of dev.

Is this something unique to my system, or is this a problem with the package? Any ideas how I can fix this?

FabianGosebrink commented 7 years ago

Have you compared your package.json to the latest version of the repo? We changed the way the "env" - variable is set. Your package.json looks like the old one.

BR

Fabian

Sent from mobile device


From: tonywr71 notifications@github.com Sent: Jul 25, 2017 17:22 To: damienbod/AngularWebpackVisualStudio Cc: Subscribed Subject: [damienbod/AngularWebpackVisualStudio] Error: cannot find module './config/webpack.undefined.js (#103)

I am trying to get this going but running into issues. Trying to run in Visual Studio 2017 Enterprise. From scratch, I built and ran the application (tried both debug and without) and it's failing to start. The error in the Task Runner explorer is D:\AngularWebpackVisualStudio-master\AngularWebpackVisualStudio-master\src\AngularWebpackVisualStudio> cmd /c SET NODE_ENV=development&& webpack --color module.js:471 throw err; ^ Error: Cannot find module './config/webpack.undefined.js' at Function.Module._resolveFilename (module.js:469:15) at Function.Module._load (module.js:417:25) at Module.require (module.js:497:17) at require (internal/module.js:20:19) at module.exports (D:\AngularWebpackVisualStudio-master\AngularWebpackVisualStudio-master\src\AngularWebpackVisualStudio\webpack.config.js:3:10) at handleFunction (D:\AngularWebpackVisualStudio-master\AngularWebpackVisualStudio-master\src\AngularWebpackVisualStudio\node_modules\webpack\lib\prepareOptions.js:26:13) at prepareOptions (D:\AngularWebpackVisualStudio-master\AngularWebpackVisualStudio-master\src\AngularWebpackVisualStudio\node_modules\webpack\lib\prepareOptions.js:11:13) at requireConfig (D:\AngularWebpackVisualStudio-master\AngularWebpackVisualStudio-master\src\AngularWebpackVisualStudio\node_modules\webpack\bin\convert-argv.js:98:14) at D:\AngularWebpackVisualStudio-master\AngularWebpackVisualStudio-master\src\AngularWebpackVisualStudio\node_modules\webpack\bin\convert-argv.js:104:17 at Array.forEach (native) Process terminated with code 1.

Firstly, I've noticed that in the web.config file it contains: /// which I thought overrode the binding in package.json: "-vs-binding": { "ProjectOpened": [ "watch-webpack-dev" ] }

Secondly, it looks like the env variable isn't being set, so its returning undefined instead of dev.

Is this something unique to my system, or is this a problem with the package? Any ideas how I can fix this?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://github.com/damienbod/AngularWebpackVisualStudio/issues/103, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AKvw_Vofss7JSLqAlV2qaKcf05gUczTZks5sRobEgaJpZM4OjSCO.

tonywr71 commented 7 years ago

This is my package.json at the moment (not sure how to get this to format correctly): { "name": "angular-webpack-visualstudio", "version": "1.0.0", "description": "An Angular VS template", "main": "wwwroot/index.html", "author": "", "license": "ISC", "repository": { "type": "git", "url": "https://github.com/damienbod/Angular2WebpackVisualStudio.git" }, "scripts": { "start": "concurrently \"webpack-dev-server --env=dev --hot --inline --port 8080\" \"dotnet run\" ", "webpack-dev": "webpack --env=dev", "webpack-production": "webpack --env=prod", "build-dev": "npm run webpack-dev", "build-production": "npm run webpack-production", "watch-webpack-dev": "webpack --env=dev --watch --color", "watch-webpack-production": "npm run build-production --watch --color", "publish-for-iis": "npm run build-production && dotnet publish -c Release", "test": "karma start", "test-watch": "karma start --no-single-run", "lint": "tslint ./angularApp" }, "dependencies": { "@angular/animations": "4.3.1", "@angular/common": "4.3.1", "@angular/compiler": "4.3.1", "@angular/compiler-cli": "4.3.1", "@angular/core": "4.3.1", "@angular/forms": "4.3.1", "@angular/http": "4.3.1", "@angular/platform-browser": "4.3.1", "@angular/platform-browser-dynamic": "4.3.1", "@angular/platform-server": "4.3.1", "@angular/router": "4.3.1", "@angular/upgrade": "4.3.1", "angular-in-memory-web-api": "0.3.2", "bootstrap": "3.3.7", "core-js": "2.4.1", "fontawesome": "4.7.2", "ie-shim": "0.1.0", "moment": "2.18.1", "rxjs": "5.4.2", "zone.js": "0.8.14" }, "devDependencies": { "@ngtools/webpack": "^1.5.1", "@types/node": "^8.0.14", "@types/jasmine": "^2.5.53", "angular-router-loader": "^0.6.0", "angular2-template-loader": "^0.6.2", "awesome-typescript-loader": "^3.2.1", "clean-webpack-plugin": "^0.1.16", "codelyzer": "^3.1.2", "concurrently": "^3.5.0", "copy-webpack-plugin": "^4.0.1", "css-loader": "^0.28.4", "file-loader": "^0.11.2", "html-webpack-plugin": "^2.29.0", "jasmine-core": "^2.6.4", "jquery": "^3.2.1", "json-loader": "^0.5.4", "karma": "^1.7.0", "karma-chrome-launcher": "^2.2.0", "karma-jasmine": "^1.1.0", "karma-sourcemap-loader": "^0.3.7", "karma-spec-reporter": "^0.0.31", "karma-webpack": "^2.0.4", "node-sass": "^4.5.3", "raw-loader": "^0.5.1", "rimraf": "^2.6.1", "sass-loader": "^6.0.6", "source-map-loader": "^0.2.1", "style-loader": "^0.18.2", "tslint": "^5.5.0", "tslint-loader": "^3.5.3", "typescript": "^2.4.2", "url-loader": "^0.5.9", "webpack": "^3.3.0", "webpack-dev-server": "^2.5.1" }, "-vs-binding": { "ProjectOpened": [ "watch-webpack-dev" ] } }

damienbod commented 7 years ago

@tonywr71 could you try "npm run build-dev" from the cmd line. Does this work?

Also which task runner are you using? You should use the npm task runner and NOT the webpack task runner.

Greetings Damien

tonywr71 commented 7 years ago

Yep that was it: I had done many of these templates but most of them use the webpack task runner. I wasn't even aware that there was a different one, hence my not noticing the different Task Runner in the docos!

tonywr71 commented 7 years ago

Ok, still trying to get this going correctly. I can see when I make changes that the application is recompiling, and that's awesome. I was running previously on the command line using npm start, and then opening up localhost:8080 and the page was turning up, and hot module replacement was occurring. Now that I am running the application inside visual studio 2017, I run the application and it opens localhost:8080, but it is giving me a 404:

IIS 10.0 DetailedError - 404.0 - Not found `HTTP Error 404.0 - Not Found The resource you are looking for has been removed, had its name changed, or is temporarily unavailable. Most likely causes: The directory or file specified does not exist on the Web server. The URL contains a typographical error. A custom filter or module, such as URLScan, restricts access to the file. Things you can try: Create the content on the Web server. Review the browser URL. Check the failed request tracing log and see which module is calling SetStatus. For more information, click here.

Detailed error information: Module IIS Web Core Notification MapRequestHandler Handler StaticFile Error Code 0x80070002 Requested URL http://localhost:8080/index.html Physical Path \home\xxxmyaccountnamereplacedherexxxx\Data\My Web Sites\WebSite1\index.html Logon Method Anonymous Logon User Anonymous Request Tracing Directory \home\xxxmyaccountnamereplacedherexxxx\Data\IISExpress\TraceLogFiles\WEBSITE1 `

Is there something obvious I'm doing wrong?

tonywr71 commented 7 years ago

I've taken a step back and started with the downloaded package again, just in case I've changed anything. The package opens up, watch-webpack-dev processes in the Task Runner Explorer, the final line being ./node_modules/html-webpack-plugin/lib/loader.js!./angularApp/index.html 397 bytes {0} [built]. I run the application (Start without debugging), and it now complains: HTTP Error 502.5 - Process Failure Common causes of this issue: The application process failed to start The application process started but then stopped The application process started but failed to listen on the configured port Troubleshooting steps: Check the system event log for error messages Enable logging the application process’ stdout messages Attach a debugger to the application process and inspect For more information visit: https://go.microsoft.com/fwlink/?LinkID=808681

I rebooted my machine, still have the same problem. Probably not an issue with the package, but oh so frustrating!

tonywr71 commented 7 years ago

Ok, I have solved my problem. I somehow had a corrupted .net core installation. I uninstalled the .net core cross platform package in VS2017, then reinstalled it, and now everything is working again. I am so relieved!