【问题标题】:How to exclude node_module folder from build in visual studio 2015 update 3如何从 Visual Studio 2015 更新 3 中的构建中排除 node_module 文件夹
【发布时间】:2017-07-31 13:22:38
【问题描述】:

我正在尝试使用 Visual Studio 作为我的 IDE,以使用 Angular 2 开发 ASP.NET MVC 5 SPA。 当我尝试构建项目时,问题就出现了。它在*.d.ts 文件中给了我很多错误。

我使用angular-cli 命令创建了项目:ng new project-name

这是解决方案资源管理器的样子:

如何消除这些错误?我在 Visual Studio Code 中使用 angular 2 没有任何问题

更新:

根据您的回答,我在tsconfig.json 文件中添加了以下内容,但似乎不起作用

{
  "compileOnSave": false,
  "compilerOptions": {
    "outDir": "./dist/out-tsc",
    "sourceMap": true,
    "declaration": false,
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "lib": [
      "es2016"
    ]
  },
  "exclude": [
    "./node_modules",
    "**/*.spec.ts"
  ]
}

【问题讨论】:

  • 编辑您的 tsconfig.json 以从编译中排除 node_modules 文件夹。
  • 我试过了,但它并没有改变@jessehouwing
  • 尝试在 Windows 资源管理器中隐藏 node_modules 目录。
  • 我已经做了,但它不起作用,我认为问题是使用 webpack @OmidKamangar 的原因
  • 删除 tsconfig.json 中的 "strict": true 为我消除了类似的错误。

标签: angular visual-studio-2015 asp.net-mvc-5 single-page-application node-modules


【解决方案1】:

确保您使用适用于您的 Visual Studio 版本的最新 Typescript 工具。我的一位同事遇到了类似的问题,如果您已经在 tsconfig 中排除了 node_modules 文件夹,这可能就是问题所在。

对于 VS 2015: https://www.microsoft.com/en-us/download/details.aspx?id=48593

【讨论】:

【解决方案2】:
{
    "compilerOptions": {
        "module": "system",
        "noImplicitAny": true,
        "removeComments": true,
        "preserveConstEnums": true,
        "outFile": "../../built/local/tsc.js",
        "sourceMap": true
    },
    "include": [
        "src/**/*"
    ],
    "exclude": [
        "node_modules",
        "**/*.spec.ts"
    ]
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-01-25
    • 1970-01-01
    • 1970-01-01
    • 2012-08-10
    • 1970-01-01
    相关资源
    最近更新 更多