【问题标题】:Typescript compile not outputting to outDir option打字稿编译不输出到 outDir 选项
【发布时间】:2020-09-02 18:35:20
【问题描述】:

我正在尝试设置一个 Typescript 项目并且在编译该项目时遇到了困难。我已将 outDir 属性设置为当前文件夹中的 dist。我尝试运行build: echo \"Hello\" and pwd 以及正确输出hello 的npm run build,以及tsconfig.json 所在的当前目录。 我的 tsconfig.json 是:

{
  "compilerOptions": {
    "baseUrl": "src",
    "declaration": true,
    "lib": ["esnext.asynciterable", "es6", "es2017"],
    "module": "commonjs",
    "moduleResolution": "node",
    "outDir": "./dist/",
    "strict": true,
    "noUnusedLocals": true,
    "noImplicitReturns": true,
    "forceConsistentCasingInFileNames": true,
    "target": "es2017",
    "typeRoots": ["./node_modules/@types", "./@types"]
  },
  "include": [
    "./src/**/*.ts"
  ]
}

我的 package.json 是:

  "scripts": {
    "build": "npm run compile",
    "compile": "tsc",
    "clean": "rm -rf node_modules dist"
  },
  "devDependencies": {
    "@types/node": "^11.13.4",
    "typescript": "^3.6.4"
  }

在我的目录中的任何地方或看起来的任何地方都没有创建 dist 文件夹。对于我的目录中的一个 ts 文件,命令行上似乎没有任何错误,也没有我传递给 tsc 的任何其他特定文件选项。我是不是初始化不正确?

【问题讨论】:

  • 您可以尝试删除baseUrl 并检查它是否解决了问题?
  • 我试过了,但还是不行。虽然我确实尝试运行 npm run compile,然后它能够​​编译并创建 dist 文件夹,但不确定为什么 build 没有运行。

标签: typescript npm tsc


【解决方案1】:

我可以通过设置让它运行:

  "npm-pretty-much": {
    "runRelease": "always"
  }, 

"release": "npm run lint && npm run compile"。不知道我在构建命令时做错了什么。

【讨论】:

    猜你喜欢
    • 2020-01-30
    • 1970-01-01
    • 2013-08-19
    • 1970-01-01
    • 2016-09-09
    • 2017-09-05
    • 2018-02-18
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多