ng-packagr:BUILD ERROR EPERM:不允许操作

时间:2018-05-04 12:14:47

标签: angular npm ng-packagr angular-ide

我按照Nikolas LeBlanc的this教程构建了一个Angular 4 Component Library。本教程描述了一种通过打包一个项目并将其安装在另一个项目中来在另一个项目中重用模块的方法。

首先,这是我的软件版本:

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

我不能按照标题"创建我们的包"进一步遵循教程,因为执行以下命令:

  

ng-packagr -p ng-package.json

执行此命令时,将发生以下错误:

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

再次尝试时会发生以下错误:

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

我也在我的Mac上尝试过,但一切正常,但我们都在Windows机器上工作。那么如何让ng-packagr在我的Windows机器上运行呢?

6 个答案:

答案 0 :(得分:3)

您可以代表管理员尝试运行命令行。也许会有所帮助

答案 1 :(得分:0)

如果某些东西锁定了文件/目录,通常会发生这种情况。对我来说,VS Code通常会这样做。

防止此错误的一种方法是[1]在Admin模式下运行(如其他答案所示),或[2]关闭VS Code并尝试

或者[3]从tsconfig.json中排除目录,例如

    "exclude": [
        "dist"
    ]

答案 2 :(得分:0)

请自行安装出现错误的模块。

花费了很多时间并尝试了所有可能的建议之后,我发现安装错误所提及的特定模块可以整体解决问题:

例如:npm ERR! {错误:EPERM:不允许执行操作,请取消链接'C:\ Path \ Docnt nts \ AngularProjects \ my-sample-app333 \ node_modules.staging@angular \ core-a3d1aa4 8 \ bundles core.umd.js

我运行: npm install -global @ angular / core

它为我修复了它!终于!

答案 3 :(得分:0)

就我而言,删除"Angular Language Service"插件对我有所帮助。

我找到了此解决方案here

答案 4 :(得分:0)

我意识到我的应用程序已处于断点……只要停止运行该应用程序,您就会很好。

答案 5 :(得分:0)

清空工作区的dist文件夹。它对我有用。