小编ben*_*ite的帖子

如何在 terraform entreprise 中使用 npm?

我尝试构建一个 React.js 应用程序,然后使用以下代码压缩它:

resource "null_resource" "build" {
  triggers = {
    always_run = "${timestamp()}"
  }
  provisioner "local-exec" {
    command = "cd ${path.module}/.. && npm run build"
    environment = var.environment_variables
  }
}
data "archive_file" "source_zip" {
  depends_on = [null_resource.build]
  type        = "zip"
  source_dir  = "../build"
  output_path = "dist/source.zip"
}
Run Code Online (Sandbox Code Playgroud)

该代码在我的本地计算机上运行良好,但在 Terraform 云(https://www.terraform.io/)上运行失败。NPM 似乎没有安装在 terraform 运行的机器上。这是我得到的错误:

Error: Error running command 'cd ./.. && npm run build': exit status 127. Output: /bin/sh: 1: npm: not found
Run Code Online (Sandbox Code Playgroud)

那么,如何在 Terraform 云上安装 npm 呢?

terraform

4
推荐指数
1
解决办法
2562
查看次数

如何在javascript中为一个大数字添加1?

如果满足某些条件,我只是想在大数字上加1.这是我的javascript:

console.log('n1->'+n1+ ' - ' + typeof(n1) );
console.log('n2->'+n2);

if(n1 != null && n2 != n1){
    console.log('adding 1');
    n2 = n1 + 1;
}
console.log('n2->'+n2);
Run Code Online (Sandbox Code Playgroud)

这是控制台输出:

n1->443751754287812600 - number
n2->null
adding 1
n2->443751754287812600
Run Code Online (Sandbox Code Playgroud)

我期待有n2=443751754287812601甚至是n2=4437517542878126001.你能解释一下它为什么不起作用吗?以及如何正确地完成总和?

谢谢你的帮助.

javascript

0
推荐指数
1
解决办法
678
查看次数

标签 统计

javascript ×1

terraform ×1