Kevin de Goede
Kevin de Goede

Reputation: 429

ng-packagr: BUILD ERROR EPERM: operation not permitted

I followed this tutorial by Nikolas LeBlanc for building an Angular 4 Component Library. The tutorial describes a way to reuse a module in another project by packaging one project and installing it in the other.

First, this are my software versions:

I can't follow the tutorial further than the heading "Create our package", because executing the following command:

ng-packagr -p ng-package.json

When executing this command the following error will occur:

npm run forestrun

[email protected] forestrun C:\Users\Kevin.DeGoede\Documents\yoyo\bte
ng-packagr -p ng-package.json

Building Angular Package
Building entry point 'bte'
Cleaning build directory
Rendering Stylesheets
Rendering Templates
Compiling TypeScript sources through ngc
Bundling to FESM15
Bundling to FESM5
Bundling to UMD
Minifying UMD bundle
Relocating source maps
Copying staged files
Writing package metadata
Distributing npm packages with 'dependencies' is not recommended. Please consider adding to 'peerDependencies' or remove it from 'dependencies'.

BUILD ERROR
EPERM: operation not permitted, unlink 'C:\Users\Kevin\Documents\yoyo\bte\dist\src\app\modules'
Error: EPERM: operation not permitted, unlink 'C:\Users\Kevin\Documents\yoyo\bte\dist\src\app\modules'

npm ERR! code ELIFECYCLE
npm ERR! errno 111
npm ERR! [email protected] forestrun: ng-packagr -p ng-package.json
npm ERR! Exit status 111
npm ERR!
npm ERR! Failed at the [email protected] forestrun script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Kevin\AppData\Roaming\npm-cache_logs\2018-05-04T08_30_30_818Z-debug.log

When trying again the following error occurs:

npm run forestrun

[email protected] forestrun C:\Users\Kevin\Documents\yoyo\bte
ng-packagr -p ng-package.json

Building Angular Package
glob error { Error: EPERM: operation not permitted, scandir 'C:\Users\Kevin\Documents\yoyo\bte\dist\src\app\modules'
errno: -4048,
code: 'EPERM',
syscall: 'scandir',
path: 'C:\Users\Kevin\Documents\yoyo\bte\dist\src\app\modules' }

BUILD ERROR
EPERM: operation not permitted, scandir 'C:\Users\Kevin\Documents\yoyo\bte\dist\src\app\modules'
Error: EPERM: operation not permitted, scandir 'C:\Users\Kevin\Documents\yoyo\bte\dist\src\app\modules'

npm ERR! code ELIFECYCLE
npm ERR! errno 111
npm ERR! [email protected] forestrun: ng-packagr -p ng-package.json
npm ERR! Exit status 111
npm ERR!
npm ERR! Failed at the [email protected] forestrun script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Kevin\AppData\Roaming\npm-cache_logs\2018-05-04T08_54_07_739Z-debug.log

I tried it also on my Mac, but everything works fine, but we all work on windows machines. So how can I get the ng-packagr to work on my windows machine?

Upvotes: 4

Views: 5102

Answers (6)

soni kumari
soni kumari

Reputation: 407

empty the dist folder of your workspace .It worked for me.

Upvotes: 2

AtLeastTheresToast
AtLeastTheresToast

Reputation: 387

I realized my application was at a break point... just stop the application from running and you will be good.

Upvotes: 1

progm
progm

Reputation: 2858

In my case, removing the "Angular Language Service" plugin helped me.

I found this solution here.

Upvotes: 0

Alberto Montellano
Alberto Montellano

Reputation: 6246

Install by yourself the module that is giving the error.

After spending many hours and trying all the possible suggestions, I found that installing the specific module mentioned by the error globally fixed the issue:

For Example: npm ERR! { Error: EPERM: operation not permitted, unlink 'C:\Path\Docume nts\AngularProjects\my-sample-app333\node_modules.staging@angular\core-a3d1aa4 8\ bundles\ core.umd.js

I run: npm install -global @angular/core

and it fixed it for me! Finally!!

Upvotes: 0

Arghya C
Arghya C

Reputation: 10068

It generally happens if something is locking the files/directories. For me, generally VS Code does this.

One way to prevent this error is to [1] run in Admin mode (as suggested in other answer), or [2] close VS Code and try

Or [3] exclude the directory from tsconfig.json like

    "exclude": [
        "dist"
    ]

Upvotes: 3

Abylay
Abylay

Reputation: 344

You can try run command line on behalf of the administrator. Maybe will help

Upvotes: 4

Related Questions