angular - ng-packagr:构建错误 EPERM:不允许操作

标签 angular npm angular-library ng-packagr

我关注了this Nikolas LeBlanc 的教程,用于构建 Angular 4 组件库。本教程描述了一种在另一个项目中重用模块的方法,方法是打包一个项目并将其安装到另一个项目中。

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

  • Windows 10 专业版:1709 内部版本 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
  • 节点: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 机器上工作呢?

    最佳答案

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

    关于angular - ng-packagr:构建错误 EPERM:不允许操作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50174721/

    相关文章:

    http - 错误 TS2346 : Supplied parameters do not match any signature of call target

    javascript - Angular DI 和继承 : injecting extensions of a base service

    Angular 2 rc.5 : It looks like you're using the old forms module

    node.js - 强制从私有(private)注册表下载 npm

    angular - 将 Angular 7 升级到 8,错误 : this. typeChecker.getTypeArguments 不是构建库上的函数

    与变量一起使用的 Angular 点击

    node.js - Node JS - 无法在 ubuntu 16.04 中安装 Node js 版本 8.9 或更高版本

    node.js - 找不到模块 Bootstrap

    angular - 将第三方库导入 Angular 库会报错

    Angular 库 - 无法读取未定义的属性 'ɵmod'