Terraform user_data ng build

时间:2017-02-16 21:45:55

标签: angular terraform ng-init

我有一个terraform脚本来支持EC2实例,该实例安装git,nvm,node和克隆来自github的angular2 repo。

# install angular cli globally
npm install -g @angular/cli &> globalCli.log
cd test
# install node_modules
npm install &> npmInstall.log
# create dist folder
ng build --output-path 'dist' >& ngBuild.log
ng update >& ngUpdate.log
#start the app
(npm start) &> npmStart.log```

由于某种原因,terrform脚本将此错误返回到ngBuild.log

Path must be a string. Received undefined
TypeError: Path must be a string. Received undefined
at assertPath (path.js:7:11)
at Object.join (path.js:1211:7)
at Function.fromProject (/test/node_modules/@angular/cli/models/config.js:53:39)
at Object.<anonymous> (/test/node_modules/@angular/cli/commands/serve.js:11:35)
at Module._compile (module.js:571:32)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load (module.js:439:3)
at Module.require (module.js:498:17)
at require (internal/module.js:20:19)
at Class.includedCommands (/test/node_modules/@angular/cli/addon/index.js:23:16)
at /test/node_modules/@angular/cli/ember-cli/lib/models/project.js:326:61
at Array.forEach (native)
at Project.addonCommands (/test/node_modules/@angular/cli/ember-cli/lib/models/project.js:325:15)
at Project.eachAddonCommand (/test/node_modules/@angular/cli/ember-cli/lib/models/project.js:360:30)
at module.exports (/test/node_modules/@angular/cli/ember-cli/lib/cli/lookup-command.js:33:13)
at CLI.<anonymous> (/test/node_modules/@angular/cli/ember-cli/lib/cli/cli.js:42:26)
at tryCatch (/fsi-ui/node_modules/rsvp/dist/rsvp.js:538:12)
at invokeCallback (/test/node_modules/rsvp/dist/rsvp.js:553:13)
at publish (/test/node_modules/rsvp/dist/rsvp.js:521:7)
at flush (/test/node_modules/rsvp/dist/rsvp.js:2373:5)
at _combinedTickCallback (internal/process/next_tick.js:67:7)
at process._tickCallback (internal/process/next_tick.js:98:9)

奇怪的是,如果我进入ec2实例并运行相同的ng build命令,它运行正常。

有什么想法吗?

1 个答案:

答案 0 :(得分:0)

如果有其他人遇到这个问题(我搜索过试图找到答案而无法找到解决我问题的答案)。

最终,它归结为@ angular / cli版本问题。当我在ec2实例中手动运行.link { position: relative; height: 20px; background-color: #ccc; } .hidden-dropdown { position: absolute; top: 20px; background-color: #eee; }时,我能够看到全局cli和本地cli之间存在差异。我更新了<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div class="link"> <p>Product</p> <div class="hidden-dropdown"> <div class="row"> <div class="small-6 large-6 columns"> <ul style="position: relative; float: left;"> <li><a href="#">Motion Sensor</a></li> <li><a href="#">Water Detector</a></li> <li><a href="#">Smart Plug</a></li> <li><a href="#">Door Sensor</a></li> <li><a href="#">Door Sensor Pro</a></li> </ul> <ul style="position: relative; float: right;"> <li><a href="#">Z-Wave Extender</a></li> <li><a href="#">Siren</a></li> <li><a href="#">Mouser</a></li> <li><a href="#">Water Valve</a></li> </ul> </div> </div> </div> </div>以使用ng build,然后必须将以下内容添加到我的package.json文件latest

我输出的日志仍然表示路径需要一个字符串,但我相信这只是一个脚本问题,它是通过terraform产生的。 angular-cli.json安装成功!