首页 > 解决方案 > Angular 9 ngcc 尝试扫描整个磁盘

问题描述

我按照 angular.io 指南将 Angular 8 迁移到 Angular 9,但是在生成 ivy 入口点时遇到了问题。

当我这样做时,我在命令执行npm install期间看到以下错误。ngcc

ngcc

Error: EPERM: operation not permitted, lstat 'E:/System Volume Information'
    at Object.lstatSync (fs.js:917:3)

我使用的是 Windows 10 和 Node 12,但我在 macOS 上尝试过,我得到了相同的结果(当然是在另一个系统保护路径上)。

按照我的安装后脚本

"postinstall": "ngcc --properties es2015 browser module main --first-only --create-ivy-entry-points"

我搜索了这个问题并提出了解决方案来更改文件夹权限,但我不想让我的操作系统不安全。

如果没有 ngcc 工作,我也不能做 ng 服务。

如何防止 ngcc 扫描整个磁盘并且只做它应该做的事情?是否有任何已知的错误?

编辑 :

tsconfig.json

{
  "compileOnSave": false,
  "compilerOptions": {
    "baseUrl": "./",
    "outDir": "./dist/out-tsc",
    "sourceMap": true,
    "declaration": false,
    "module": "esnext",
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "importHelpers": true,
    "target": "es2015",
    "typeRoots": ["node_modules/@types"],
    "lib": ["es2018", "dom"],
    "paths": {
      "@app/*": ["src/app/*"],
      "@src/*": ["src/*"],
      "@root/*": ["/*"]
    }
  }
}

标签: angularnpm-installangular-ivy

解决方案


问题出在 tsconfig.js

{
    ...
    "paths": {
      "@app/*": ["src/app/*"],
      "@src/*": ["src/*"],
      "@root/*": ["/*"]
    }
    ...
}

我希望@root 路径仅针对项目的根目录,但我忘记了使它相对的点

"@root/*": ["./*"]


推荐阅读