4

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:

  • Windows 10 Pro: 1709 Build 16299.371
  • Angular IDE: 17.0.0.c0000019t201804160508
  • ng-packagr: 2.4.2
  • @angular/*: 5.2.10
  • typescript: 2.5.3
  • rxjs: 5.5.10
  • node: 9.4.0
  • npm: 5.6.0

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

bte@0.0.0 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! bte@0.0.0 forestrun: ng-packagr -p ng-package.json
npm ERR! Exit status 111
npm ERR!
npm ERR! Failed at the bte@0.0.0 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

bte@0.0.0 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! bte@0.0.0 forestrun: ng-packagr -p ng-package.json
npm ERR! Exit status 111
npm ERR!
npm ERR! Failed at the bte@0.0.0 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?

progm
  • 2,782
  • 3
  • 14
  • 32
Kevin de Goede
  • 429
  • 6
  • 12

6 Answers6

4

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

Abylay
  • 344
  • 2
  • 11
  • 1
    This didnt resolve my error, but it worked using the powershell instead of the commandline! But to be sure I started is as administrator, so I think your answer helped! – Kevin de Goede May 04 '18 at 13:32
  • 1
    Curiously, running ng from PowerShell with admin rights seemed to fix the problem for me too. – Alberto Chiesa Feb 11 '19 at 16:53
3

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"
    ]
Arghya C
  • 9,805
  • 2
  • 47
  • 66
2

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

soni kumari
  • 313
  • 4
  • 4
1

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

0

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!!

Alberto Montellano
  • 5,886
  • 7
  • 37
  • 53
0

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

I found this solution here.

progm
  • 2,782
  • 3
  • 14
  • 32