Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio 2017 Angular template stuck in installing node modules

Tags:

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?

like image 393
mohammad rostami siahgeli Avatar asked Jan 07 '18 15:01

mohammad rostami siahgeli


2 Answers

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

like image 119
hlovdal Avatar answered Sep 23 '22 13:09

hlovdal


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
like image 27
Rainer Avatar answered Sep 22 '22 13:09

Rainer