【问题标题】:I am trying to build a npm package after forking it from github but i am getting this error我正在尝试从 github 分叉后构建一个 npm 包,但我收到此错误
【发布时间】:2018-02-01 10:04:06
【问题描述】:

这是 github 仓库 - https://github.com/jasonhodges/ngx-gist

当我运行打包命令时

rimraf dist && tsc -p tsconfig-esm.json && rollup -c rollup.config.js dist/ngx-gist.module.js > dist/ngx-gist.bundle.js && cp package.json dist && ts-node tools/cleanup.ts && ngc && cp README.md dist

我收到以下错误 -

/usr/lib/nodejs/typescript/tsc.js:37290
            var jsonOptions = json["compilerOptions"];
TypeError: Cannot read property 'compilerOptions' of undefined

如何解决这个错误?

更新

编译器选项

{
  "compilerOptions": {
    "target": "es5",
    "module": "es2015",
    "sourceMap": true,
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "stripInternal": true,
    "declaration": true,
    "outDir": "./dist",
    "lib": ["es2015", "dom"]
  },
  "files": [
    "./lib/ngx-gist.module.ts"
  ]
}

【问题讨论】:

    标签: node.js angular npm node-modules


    【解决方案1】:

    如果文件 tsconfig-esm.json 位于项目的根目录中,则很可能此 JSON 文件的格式存在问题。它的结构必须如下:

    {
       "compilerOptions": {
        ...
       }
    }
    

    另一个可能的原因是您在计算机上使用了旧版本的 tsc。

    【讨论】:

    • 如果你检查我正在克隆的 repo 并且只是运行命令并且仍然是错误,它已经有 npm 包。我将更新编译器选项 2
    猜你喜欢
    • 2019-09-08
    • 2021-02-16
    • 1970-01-01
    • 1970-01-01
    • 2019-05-23
    • 1970-01-01
    • 1970-01-01
    • 2020-06-15
    • 1970-01-01
    相关资源
    最近更新 更多