11

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.
nicholas_
  • 319
  • 1
  • 2
  • 10

11 Answers11

12

Restarting the machine worked for me.

Dulanjaya Tennekoon
  • 1,727
  • 1
  • 12
  • 25
9

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

nicholas_
  • 319
  • 1
  • 2
  • 10
7

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

Qadir Hussain
  • 8,338
  • 11
  • 82
  • 117
  • 1
    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. – Edwin Pratt Jan 23 '21 at 22:42
2

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

1

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
  • 527
  • 5
  • 8
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'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. :)

Edwin Pratt
  • 699
  • 8
  • 19
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
  • 21
  • 3
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
  • 518
  • 4
  • 17
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
  • 1,752
  • 12
  • 18
-1

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