質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.50%
Bluemix

Bluemixは、IBMが提供しているソフトウェア込みのクラウドプラットフォーム (PaaS) です。開発環境と実行環境をクラウドサービス上で利用することが可能で、開発言語としてSwift/Java/JavaSciptなどの主要な言語を全て使用することができます。

Node.js

Node.jsとはGoogleのV8 JavaScriptエンジンを使用しているサーバーサイドのイベント駆動型プログラムです。

TypeScript

TypeScriptは、マイクロソフトによって開発された フリーでオープンソースのプログラミング言語です。 TypeScriptは、JavaScriptの構文の拡張であるので、既存の JavaScriptのコードにわずかな修正を加えれば動作します。

Q&A

0回答

2091閲覧

nodeモジュールをBluemixへデプロイ出来ない

motuo

総合スコア3027

Bluemix

Bluemixは、IBMが提供しているソフトウェア込みのクラウドプラットフォーム (PaaS) です。開発環境と実行環境をクラウドサービス上で利用することが可能で、開発言語としてSwift/Java/JavaSciptなどの主要な言語を全て使用することができます。

Node.js

Node.jsとはGoogleのV8 JavaScriptエンジンを使用しているサーバーサイドのイベント駆動型プログラムです。

TypeScript

TypeScriptは、マイクロソフトによって開発された フリーでオープンソースのプログラミング言語です。 TypeScriptは、JavaScriptの構文の拡張であるので、既存の JavaScriptのコードにわずかな修正を加えれば動作します。

0グッド

0クリップ

投稿2017/09/28 07:40

このチュートリアル通りの手順にて、Bluemixにアプリケーションをデプロイしようとしたところ、下記のエラーにてエラーとなってしまいました。(4.5.3 Cloud Foundry にデプロイを行うの箇所です)

[APP/PROC/WEB/0] ERR /home/vcap/app/node_modules/ts-node/src/index.ts:300 [APP/PROC/WEB/0] ERR throw new TSError(formatDiagnostics(diagnosticList, cwd, ts, lineOffset)) [APP/PROC/WEB/0] ERR server/watson-auth-service.ts (2,23): Cannot find module 'path'. (2307) [APP/PROC/WEB/0] ERR server/watson-auth-service.ts (3,21): Cannot find module 'fs'. (2307) [APP/PROC/WEB/0] ERR server/watson-auth-service.ts (5,53): Cannot find name '__dirname'. (2304) [APP/PROC/WEB/0] ERR at getOutput (/home/vcap/app/node_modules/ts-node/src/index.ts:300:15) [APP/PROC/WEB/0] ERR at Module.m._compile (/home/vcap/app/node_modules/ts-node/src/index.ts:382:43) [APP/PROC/WEB/0] ERR at tryModuleLoad (module.js:446:12) [APP/PROC/WEB/0] ERR npm ERR! argv "/home/vcap/app/vendor/node/bin/node" "/home/vcap/app/vendor/node/bin/npm" "start" [APP/PROC/WEB/0] ERR npm ERR! demo@0.0.0 start: `NODE_ENV=production PORT=8080 ts-node server` [APP/PROC/WEB/0] ERR npm ERR! not with npm itself. [APP/PROC/WEB/0] ERR npm ERR! Tell the author that this fails on your system: [APP/PROC/WEB/0] ERR npm ERR! You can get information on how to open an issue for this project with: [APP/PROC/WEB/0] ERR npm ERR! npm bugs demo [APP/PROC/WEB/0] ERR npm ERR! Or if that isn't available, you can get their info via: [CELL/0] OUT Destroying container [CELL/0] OUT Successfully created container [CELL/0] OUT Successfully destroyed container [CELL/0] OUT Starting health monitoring of container [APP/PROC/WEB/0] OUT > NODE_ENV=production PORT=8080 ts-node server [APP/PROC/WEB/0] ERR throw new TSError(formatDiagnostics(diagnosticList, cwd, ts, lineOffset)) [APP/PROC/WEB/0] ERR ^ [APP/PROC/WEB/0] ERR TSError: ⨯ Unable to compile TypeScript [APP/PROC/WEB/0] ERR at getOutput (/home/vcap/app/node_modules/ts-node/src/index.ts:300:15) [APP/PROC/WEB/0] ERR at /home/vcap/app/node_modules/ts-node/src/index.ts:330:16 [APP/PROC/WEB/0] ERR at Object.compile (/home/vcap/app/node_modules/ts-node/src/index.ts:489:17) [APP/PROC/WEB/0] ERR at Module._extensions..js (module.js:579:10) [APP/PROC/WEB/0] ERR at Module.load (module.js:487:32) [APP/PROC/WEB/0] ERR at tryModuleLoad (module.js:446:12) [APP/PROC/WEB/0] ERR at Function.Module._load (module.js:438:3) [APP/PROC/WEB/0] ERR at Module.require (module.js:497:17) [APP/PROC/WEB/0] ERR npm ERR! Linux 4.4.0-75-generic [APP/PROC/WEB/0] ERR npm ERR! argv "/home/vcap/app/vendor/node/bin/node" "/home/vcap/app/vendor/node/bin/npm" "start" [APP/PROC/WEB/0] ERR npm ERR! node v6.11.1 [APP/PROC/WEB/0] ERR npm ERR! npm v3.10.10 [APP/PROC/WEB/0] ERR npm ERR! code ELIFECYCLE [APP/PROC/WEB/0] ERR npm ERR! demo@0.0.0 start: `NODE_ENV=production PORT=8080 ts-node server` [APP/PROC/WEB/0] ERR npm ERR! Exit status 1 [APP/PROC/WEB/0] ERR npm ERR! [APP/PROC/WEB/0] ERR npm ERR! Make sure you have the latest version of node.js and npm installed. [APP/PROC/WEB/0] ERR npm ERR! If you do, this is most likely a problem with the demo package, [APP/PROC/WEB/0] ERR npm ERR! not with npm itself. [APP/PROC/WEB/0] ERR npm ERR! Tell the author that this fails on your system: [APP/PROC/WEB/0] ERR npm ERR! NODE_ENV=production PORT=8080 ts-node server [APP/PROC/WEB/0] ERR npm ERR! You can get information on how to open an issue for this project with: [APP/PROC/WEB/0] ERR npm ERR! npm bugs demo [APP/PROC/WEB/0] ERR npm ERR! npm owner ls demo [APP/PROC/WEB/0] ERR npm ERR! There is likely additional logging output above. [APP/PROC/WEB/0] ERR npm ERR! Please include the following file with any support request: [APP/PROC/WEB/0] ERR npm ERR! /home/vcap/app/npm-debug.log

エラー内容を見ると下記のソースのpathfs等が見つからないと怒られているようです…
watson-auth-service.ts

import * as watson from 'watson-developer-cloud'; import * as path from 'path'; import * as fs from 'fs'; const secret = JSON.parse(fs.readFileSync(path.join(__dirname, 'credential.json'), 'utf8')); const authConfig = { version: 'v1', url: secret.url, username: secret.username, password: secret.password }; const watsonAuthService = watson.authorization(authConfig); export function getAuthToken(): Promise<string> { return new Promise<string>((resolve, reject) => { watsonAuthService.getToken({ url: authConfig.url }, (err, token: string) => { if (err) { reject(err); } resolve(token); }); }); }

index.js

javascript

1const path = require('path'); 2const express = require('express'); 3const bodyParser = require('body-parser'); 4const app = express(); 5const server = require('http').createServer(app); 6const port = process.env.PORT || 3000; 7const watsonAuthService = require('./watson-auth-service'); 8 9app.use(function(req, res, next) { 10 res.header('Access-Control-Allow-Methods', 'GET, PUT, POST, DELETE, OPTION'); 11 res.header('Access-Control-Allow-Origin', '*'); 12 res.header('Access-Control-Allow-Headers', 'Origin, X-Requested-With, Content-Type, Accept'); 13 next(); 14}); 15 16app.use(bodyParser()); 17 18app.use(express.static(path.resolve(__dirname,'../','dist'))); 19 20server.listen(port, process.env.OPENSHIFT_NODEJS_IP || process.env.IP || undefined, function() { 21 console.log('Express server listening on %d, in %s mode', port, app.get('env')); 22}); 23 24app.get('/auth', function(req, res, next) { 25 watsonAuthService.getAuthToken().then((token,err)=>res.json({token})); 26}); 27 28app.get('/', function(req, res, next) { 29 res.render('index'); 30});

しかしながら、ローカル環境では稼働するので、pacage.jsonの設定がおかしいのかも?と思いながらも中々、とっかかりがつかめずにいます。
package.json

{ "name": "demo", "version": "0.0.0", "license": "MIT", "scripts": { "ng": "ng", "start": "NODE_ENV=production PORT=8080 ts-node server", "server": "ts-node server | ng serve --proxy-config proxy.config.json && wait", "build": "ng build", "test": "ng test", "lint": "ng lint", "e2e": "ng e2e" }, "private": true, "dependencies": { "body-parser": "^1.18.0", "express": "^4.15.4", "ts-node": "~3.0.4", "typescript": "~2.3.3", "watson-developer-cloud": "^2.39.0", "watson-speech": "^0.33.1" }, "devDependencies": { "@angular/cli": "1.2.0-rc.0", "@angular/compiler-cli": "^4.0.0", "@angular/language-service": "^4.0.0", "@types/jasmine": "2.5.45", "@types/node": "~6.0.60", "codelyzer": "~3.0.1", "jasmine-core": "~2.6.2", "jasmine-spec-reporter": "~4.1.0", "karma": "~1.7.0", "karma-chrome-launcher": "~2.1.1", "karma-cli": "~1.0.1", "karma-jasmine": "~1.1.0", "karma-jasmine-html-reporter": "^0.2.2", "karma-coverage-istanbul-reporter": "^1.2.1", "protractor": "~5.1.2", "ts-node": "~3.0.4", "tslint": "~5.3.2", "typescript": "~2.3.3", "@angular/animations": "^4.0.0", "@angular/common": "^4.0.0", "@angular/compiler": "^4.0.0", "@angular/core": "^4.0.0", "@angular/forms": "^4.0.0", "@angular/http": "^4.0.0", "@angular/platform-browser": "^4.0.0", "@angular/platform-browser-dynamic": "^4.0.0", "@angular/router": "^4.0.0", "body-parser": "^1.18.1", "core-js": "^2.4.1", "express": "^4.15.4", "rxjs": "^5.1.0", "watson-developer-cloud": "^2.39.0", "zone.js": "^0.8.4" } }

完成品のソースをデプロイしようとしても同じエラーとなるので、何かオペレーション手順が漏れてしまっているのかもしれません。

何かわかる方がいらっしゃったらご教示頂けると助かります。
宜しくお願い致します。

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだ回答がついていません

会員登録して回答してみよう

アカウントをお持ちの方は

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.50%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問