Visual Studio 2017 Angular template stuck in installing node modules

Using Angular template of VS 2017, I created a project.

Then when I tried to build it, it showed this message in the output window:

Build delayed until Bower/npm packages finish restoring.

And the problem is that it's stuck in this state for hours. I checked and noticed that the solution folder's size is not increased. I also checked my internet usage and there is no send or receive.

VS version: Visual Studio Community 2017 15.5.2

What should I do?

Upvotes: 5

Views: 5703

Answers (6)

Vitor Ceolin
Vitor Ceolin

Reputation: 206

For anyone hopeless, if you wait a looooong time (for me it was like 10 minutes), eventually the build finishes. The problem is that every first time you try to build/run your project after opening Visual Studio you will need to wait this amount of time.

Upvotes: 0

Robert
Robert

Reputation: 564

Long time ago, I faced the same problem, the quickest fix is to go in the folder location with terminal and type:

npm install

Long time ago, I wrote an article about it: https://medium.com/@roberturturica/npm-bower-install-in-visual-studio-core-c9e370a59e87

Upvotes: 0

enthusiast
enthusiast

Reputation: 999

I faced the same problem. Even all the nuget packages were downloaded but still VS was showing the "Build delayed until Bower/npm packages finish restoring." message forever while building. Below steps solved it for me -

  1. I had one angular 6 project in the solution. From build->configuration manager I changed not to build the angular project and from command prompt I did npm install in the that directory.
  2. Still the same issue. I had one asp .net core api project and few other class library projects in the solution. I manually deleted the contents of bin and obj folder for each project in the solution and reopened VS and then build worked fine.

Hope this will help someone facing the same issue.

Upvotes: 0

Rainer
Rainer

Reputation: 21

The following worked for me:

  1. I closed Visual Studio 2017 (apparently it was holding onto some files that the 'npm install' needed to rename)
  2. I opened up a command prompt as administrator
  3. Changed directory to the project folder (the folder where the *.sln file sits)
  4. In that folder I ran 'npm install'
  5. Reopened Visual Studio 2017, and build the solution

Upvotes: 2

Vahid Ghadiri
Vahid Ghadiri

Reputation: 4076

For my changing the project directory and then cleaning the solution works.

Upvotes: 0

hlovdal
hlovdal

Reputation: 28180

What I did:

  • Close visual studio.
  • Delete all bin and obj folders completely (not just a clean build/rebuild)1.

Try this and see if it helps.


Not 100% sure if that was the exact trigger, "Dependencies -> npm" in solution explorer was also complained about node-sass not being installed (and node_modules/node-sass was not present). Running yarn did not install anything because it thought it already was installed (because it was listed in packages.json and yarn.lock). Installing a newer version of node-sass populated node_modules/node-sass. So it might also be a problem that is solved by running

find . -name node_modules -print \
| grep -v /node_modules/.*/node_modules \
| tr '\012' '\000' | xargs -0 rm -r

1 From a git bash prompt: find . -name node_modules -prune -o -iname bin -print0 -o -iname bin -print0 | xargs -0 --no-run-if-empty rm -r

Upvotes: 2

Related Questions