29

I keep getting the same error message when trying to create a new angular project. I tried to create a new angular project using Windows Powershell with the following commands:

ng new hello-world

-> Would you like to add angular routing? - Yes

-> Stylesheet format? - CSS

I obtained the error message below. I already tried to reinstall angular cli and I'm running Powershell using Administrator.

Installed versions:

Angular CLI: 8.0.6

Node: 10.16.0

OS: win32 x64

Error message:

npm WARN tarball data for tslint@~5.15.0 (sha512-6bIEujKR21/3nyeoX2uBnE8s+tMXCQXhqMmaIPJpHmXJoBJPTLcI7/VHRtUwMhnLVdwLqqY3zmd8Dxqa5CVdJA==) seems to be corrupted. Trying one more time.
npm WARN tarball tarball data for jasmine-spec-reporter@~4.2.1 (sha512-FZBoZu7VE5nR7Nilzy+Np8KuVIOxF4oXDPDknehCYBDE080EnlPu0afdZNmpGDBRCUBv3mj5qgqCRmk6W/K8vg==) seems to be corrupted. Trying one more time.
npm WARN tarball tarball data for acorn@^6.0.5 (sha512-jPTiwtOxaHNaAPg/dmrJ/beuzLRnXtB0kQPQ8JpotKJgTB6rX6c8mlf315941pyjBSaPg8NHXS9fhP4u17DpGA==) seems to be corrupted. Trying one more time.
npm WARN tarball tarball data for @angular/language-service@~8.0.3 (sha512-04XojOo9FJgEQE/rZafnaJQxPEU+//TSzTgpGoIVzCSMx+joCY/ZSSwJZPWxiHlOE57W/zX02ZY+TwcM81oTdw==) seems to be corrupted. Trying one more time.
npm WARN tar ENOENT: no such file or directory, open 'C:\Users\konta\Desktop\Programming_files\Angular\hello-world\node_modules\.staging\@angular\platform-browser-447d0944\esm2015\animations\src\animation_builder.js'
npm ERR! path C:\Users\konta\Desktop\Programming_files\Angular\hello-world\node_modules\.staging\jasmine-spec-reporter-cbb15ffc\screenshot.gif
npm ERR! code EPERM
npm ERR! errno -4048
npm ERR! syscall unlink
npm ERR! Error: EPERM: operation not permitted, unlink 'C:\Users\konta\Desktop\Programming_files\Angular\hello-world\node_modules\.staging\jasmine-spec-reporter-cbb15ffc\screenshot.gif'
npm ERR!  { [Error: EPERM: operation not permitted, unlink 'C:\Users\konta\Desktop\Programming_files\Angular\hello-world\node_modules\.staging\jasmine-spec-reporter-cbb15ffc\screenshot.gif']
npm ERR!   cause:
npm ERR!    { Error: EPERM: operation not permitted, unlink 'C:\Users\konta\Desktop\Programming_files\Angular\hello-world\node_modules\.staging\jasmine-spec-reporter-cbb15ffc\screenshot.gif'
npm ERR!      errno: -4048,
npm ERR!      code: 'EPERM',
npm ERR!      syscall: 'unlink',
npm ERR!      path:
npm ERR!       'C:\\Users\\konta\\Desktop\\Programming_files\\Angular\\hello-world\\node_modules\\.staging\\jasmine-spec-reporter-cbb15ffc\\screenshot.gif' },
npm ERR!   stack:
npm ERR!    'Error: EPERM: operation not permitted, unlink \'C:\\Users\\konta\\Desktop\\Programming_files\\Angular\\hello-world\\node_modules\\.staging\\jasmine-spec-reporter-cbb15ffc\\screenshot.gif\'',
npm ERR!   errno: -4048,
npm ERR!   code: 'EPERM',
npm ERR!   syscall: 'unlink',
npm ERR!   path:
npm ERR!    'C:\\Users\\konta\\Desktop\\Programming_files\\Angular\\hello-world\\node_modules\\.staging\\jasmine-spec-reporter-cbb15ffc\\screenshot.gif',
npm ERR!   parent: 'hello-world' }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It's possible that the file was already in use (by a text editor or antivirus),
npm ERR! or that you lack permissions to access it.
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator (though this is not recommended).
npm WARN tar EPERM: operation not permitted, lstat 'C:\Users\konta\Desktop\Programming_files\Angular\hello-world\node_modules\.staging\@angular\router-8388bfd5\esm2015\src\directives'
npm WARN tarball tarball data for typescript@3.4.4 (sha512-xt5RsIRCEaf6+j9AyOBgvVuAec0i92rgCaS3S+UVf5Z/vF2Hvtsw08wtUTJqp4djwznoAgjSxeCcU4r+CcDBJA==) seems to be corrupted. Trying one more time.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\konta\AppData\Roaming\npm-cache\_logs\2019-07-01T01_21_13_653Z-debug.log
Package install failed, see above.
nicho
  • 645
  • 1
  • 5
  • 15

16 Answers16

21

In windows10 I disabled the windows defender / windows security ==> realtime protection and try again npm install command and it worked

1. enter image description here

2. enter image description here

3. enter image description here

NOTE : Turn on the real time protection again after installation complete.

Qadir Hussain
  • 8,721
  • 13
  • 89
  • 124
  • 3
    The issue with this is now you PC or laptop is not protected... There's an option in Windows Security that allows you to exclude files. – Ed The ''Pro'' Jan 23 '21 at 22:42
  • 1
    As an absolute newbie to Node, this is horrible. Why would a software as mature as nodejs would need to turn off the virus protection. This is wrong on many level. – Rajesh Swarnkar Feb 02 '22 at 13:02
20

I found the problem: My antivirus was somehow blocking the files without me knowing. It worked once I paused my antivirus during the installation.

nicho
  • 645
  • 1
  • 5
  • 15
14

Restarting the machine worked for me.

Dulanjaya Tennekoon
  • 2,408
  • 1
  • 18
  • 31
13

I had this problem on MAC. I just added 'sudo' before the command and it worked.

sudo npm install -g parcel-bundler
Martin Oputa
  • 349
  • 4
  • 6
6

I tried opening CMD with Run as Admisnistrator then run npm i and it worked for me

Muhammad Areeb
  • 139
  • 2
  • 5
  • 1
    If you are running this command through a terminal in an IDE (eg: Webstorm etc.) you can run the IDE as administrator as well. Then the IDE terminals also get administrator privileges – Dilini Peiris Jul 01 '22 at 06:18
4

I'd just like to add a small little answer based on Qadir Hussain's answer.

If you disable "Realtime Protection" in Windows Security, you're going to leave your laptop or PC vulnerable to any viruses that may infect it when "Realtime Protection" is off. This may seem a bit impossible if you're only installing an NPM package, but some apps may have a hidden background process waiting for "Realtime Protection" to be disabled, and when it is, it could inject a virus.

That been said, there's still an option.

  1. First things first, open Windows Security by typing "Windows Security" in the Start Menu and tap "Open".

Type "Windows Security in the Start Menu and tap "Open".

  1. After that, go to "Virus & Threat Protection".

Go to "Virus & Threat Protection".

  1. Next, scroll down until you find "Manage Settings" under "Virus & Threat Protection Settings".

Scroll down until you find "Manage Settings" under "Virus & Threat Protection Settings".

  1. Then, scroll down until you see "Exclusions". Under "Exclusions" there's a link that says "Add or remove exclusions".

Scroll down until you see the link that says "Add or remove exclusions".

  1. Once that's done, tap the button that says "Add an exclusion". Then tap "Folder" on the drop-down menu.

Tap the button that say "Add an exclusion". Then tap "Folder" on the drop-down menu.

  1. Choose the node_modules directory that is giving issues.

  2. Last but not least, Allow administrative permissions.

  3. Finally, exit Windows Security.

I wouldn't recommend excluding your entire Projects folder, as that will disable all scans for the directory.

Small disclaimer here, I'm only making this answer as a means of helping others without disabling "Realtime Protection". While I'm not encouraging this, this might help fix a common problem.

Have a good day. :)

Ed The ''Pro''
  • 875
  • 10
  • 22
2

For me, there are several possibilities:

  1. Intercepted by anti-virus software, resulting in inoperability.

  2. It is locked by IDE, resulting in inoperable.

  3. The task is locked by npm running, resulting in inoperable.

Lancer.Yan
  • 857
  • 13
  • 10
2

For me the issue was with npm version I was using. I changed to a npm version which did not have the bug by using the below command:

npm install --global npm@8.3.1

I found this solution in a github issue:

Link to github issue

Hope it helps you like it did me!

Patrick Sierak
  • 129
  • 1
  • 2
1

Cancelling the npm start process and closing the terminal window (I use Hyper Terminal) worked for me (using Win 10).

I was then able to uninstall an npm package and install another.

  • 1
    I had trouble installig npm packages for my React Native project and killing the npm start process worked for me. You have my thanks! – Delice Dec 24 '20 at 14:45
1

I had visual studio code running. I turned it off and boom! worked for me!

augustino
  • 429
  • 4
  • 4
1

To me, using Windows 10 the only thing that solved this problem was: exclude the node_modules folder, open Visual Studio Code in Admin mode in the project folder, and execute the following command:

npm install -g --unsafe-perm
0

was facing this problem and this is how it got solved : -stoping the execution of the development server for both front-end and backend:enter image description here

enter image description here

Lcool
  • 321
  • 2
  • 5
0

two things:

  1. try admin.
  2. make sure other processes does not occupying the folder/file

with me, it was not related to antivirus. it appears that a process occupied this folder. in my case a node process occupied my node_modules folder. i found it out by using process-explorer - i searched the path end found that a node process using this folder(even though I closed it! very common in windows), so i ended this process and then i did not got this error anymore.

Eliav Louski
  • 3,593
  • 2
  • 28
  • 52
0

I had the same issue What I have done wrong is I had set the npm registry to a local registry, without knowing that I faced this issue once I reset to globally using npm config set registry https://registry.npmjs.org/ error went away.

Bawantha
  • 3,644
  • 4
  • 24
  • 36
0

I tried everything above.

Deleting node_modules and re-installing did the trick for me.

lejlun
  • 4,140
  • 2
  • 15
  • 31
0

This happened when I tried installing a new npm dependency, jest, with:

npm i --save-dev jest

I got it working by simply rerunning the command.

thegoodhunter-9115
  • 317
  • 1
  • 3
  • 15