使用ng build --prod使用CLI构建Angular 5项目

时间:2018-04-23 15:35:27

标签: angular5

当我使用

构建我的angular 5项目时
models.Venta.findAll({
  where: {
    fechaExpedicion: {
      [Op.gte]: '2018-03-31 00:00:00',
      [Op.lte]: '2018-03-31 23:59:59'
    }
  },
  logging: console.log,
  attributes: [
            'elaboradoPor',
            [Sequelize.fn('SUM', Sequelize.col('total')), 'totalSuma'],
            [Sequelize.fn('SUM', Sequelize.col('totalIva')), 'totalIva'],
            [Sequelize.fn('SUM', Sequelize.col('saldo')), 'totalSaldo']
            ],
        group: ['elaboradoPor']
})
.then(resultados => {
  console.log(JSON.stringify(resultados))
})
.catch(e => { console.log(e) 
})

它给出了如下的长错误。它显示了部分错误。

ng build --prod

在我添加tsconfig.json之后,如下所示也会再次出错。

error TS5055: Cannot write file 'E:/Files/dash- 
functional/node_modules/zone.js/dist/long-stack-trace-zone.js' because it 
would overwrite in
put file.
Adding a tsconfig.json file will help organize projects that contain both 
TypeScript and JavaScript files. Learn more at https://aka.ms/t
sconfig.
error TS5055: Cannot write file 'E:/Files/dash- 
functional/node_modules/zone.js/dist/proxy.js' because it would overwrite 
input file.
Adding a tsconfig.json file will help organize projects that contain both 
TypeScript and JavaScript files. Learn more at https://aka.ms/t
sconfig.
error TS5055: Cannot write file 'E:/Files/dash- 
functional/node_modules/zone.js/dist/sync-test.js' because it would 
overwrite input file.
Adding a tsconfig.json file will help organize projects that contain both 
TypeScript and JavaScript files. Learn more at https://aka.ms/t
sconfig.
error TS5055: Cannot write file 'E:/Files/dash- 
functional/node_modules/zone.js/dist/zone.js' because it would overwrite 
input file.
Adding a tsconfig.json file will help organize projects that contain both 
TypeScript and JavaScript files. Learn more at https://aka.ms/t
sconfig.

我该如何解决这个问题。在编译(ng serve)和没有prod模式的情况下构建时,该错误未显示。(ng build)

1 个答案:

答案 0 :(得分:0)

问题是TypeScript编译器正在处理.ts文件夹中的node_modules文件。您需要在exclude文件中添加.tsconfig数组。您可以在TypeScript docs中了解有关.tsconfig文件的详情。

{
    "compilerOptions": {...},
    "exclude": [
        "node_modules"
    ]
}

您是如何创建Angular项目的?如果您使用Angular CLI,它将为您创建此文件。您可能希望使用Angular CLI生成示例项目,并复制/粘贴它生成的.tsconfig文件(甚至可以将其用作项目的起点)。