11

I have pulled an existing ASP.NET Core application that previously worked on a different computer.

When I run the application on this computer, I get the following error:

AggregateException: One or more errors occurred. (Cannot find module './wwwroot/dist/vendor-manifest.json'
Error: Cannot find module './wwwroot/dist/vendor-manifest.json'
at Function.Module._resolveFilename (module.js:547:15)
at Function.Module._load (module.js:474:25)

If I Google that, I end up here, but if I run that I get:

PM> webpack --config webpack.config.vendor.js
webpack : C:\node_modules\webpack-cli\bin\webpack.js:242
At line:1 char:1
+ webpack --config webpack.config.vendor.js
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (C:\node_modules...\webpack.js:242:String) [], RemoteException
    + FullyQualifiedErrorId : NativeCommandError

                throw err;
                ^

Error: Cannot find module 'C:\Users\LarsHoldgaard\Documents\Github\Likvido.CreditRisk\Likvido.CreditRisk\webpack.config.vendor.js'
    at Function.Module._resolveFilename (module.js:547:15)

Now, this is weird to me.

I have tried to run the npm install and aspnet restore. I can run the Grunt (task runner) without failures. NPM / Node is in my PATH and I run on Windows.

I do not have a wwwroot/DIST folder from any of these actions, which I guess is the problem.

Any idea what I am doing wrong here? :-)

EDIT:

Marc asked me if it is in the tree. Apparently, it is:

enter image description here

I am unsure how this changes things.

Lars Holdgaard
  • 9,496
  • 26
  • 102
  • 182
  • Do you have a `webpack.config.vendor.js` somewhere else in the tree? – Marc LaFleur Apr 09 '18 at 15:49
  • @MarcLaFleur Please see my edit :) How this can help! – Lars Holdgaard Apr 10 '18 at 06:40
  • I think the main problem is that the DIST folder is not being made – Lars Holdgaard Apr 10 '18 at 06:41
  • @LarsHoldgaard try to run this command on root folder `webpack --config webpack.config.vendor.js` – Bharat Apr 10 '18 at 06:44
  • @Bharat That gives me the second error in the original question, which is weird because: http://prntscr.com/j36t8g <-- the file should be there at that path – Lars Holdgaard Apr 10 '18 at 06:52
  • ok, I believe second error is the one that you need to resolve, can you try to create new project of your kind and build webpack? it will give you idea on this error. – Bharat Apr 10 '18 at 06:57
  • @Bharat Actually a great point. I could create a new solution and it worked, so I guess it's installed correctly in my PATH and the global packages are in order. I could also build and got a DIST folder in the other solution... Interesting... Gives some room to debug – Lars Holdgaard Apr 10 '18 at 09:14
  • @LarsHoldgaard you are on the right way now, carry on.. – Bharat Apr 10 '18 at 11:17

4 Answers4

29

My problem solved by running these commands :

node node_modules/webpack/bin/webpack.js --config webpack.config.vendor.js
node node_modules/webpack/bin/webpack.js
Sadegh Ghanbari
  • 1,271
  • 15
  • 29
6

This was probably a caching problem, based on I just installed Node.js+NPM and Webpack.

What I did was the following:

  1. Made sure to restart my computer
  2. Verify that all dependencies was good: Node.js+NPM installed, Node in PATH, Webpack installed globally
  3. Clean everything in my solution
  4. Rebuild in Visual Studio

It suddenly started working in my end after a couple of times, so pretty sure it's some local cache that caused the problem from not having the dependencies in order.

Another trick I tried was to pull an earlier version of the application from my repo, which seemed to "refresh" the cache (or whatever was the problem). After going back to an earlier version and then back to the newest, things just worked.

Lars Holdgaard
  • 9,496
  • 26
  • 102
  • 182
0

Open package.config and note down the production build script name. Here it is production

// package.json    

{
      "name": "my-proj",
      "version": "1.0.0",
      "private": true,
      "scripts": {
        "start:dev": "cross-env DEBUG=true webpack-dev-server",
        "production": "webpack -p"
      },
      "devDependencies": {
      ...

Then execute the command

C:\my-proj>>npm run production

This will create the dist folder

Then run the project

Sukesh Chand
  • 2,339
  • 2
  • 21
  • 29
-1

I was having the same issues. The following worked for me:

1) Clean Solution
2) Rebuild Solution
3) Run the Project
MattE
  • 1,044
  • 1
  • 14
  • 34