2017-12-20 20 views
-1

Google App Engineでナイトメアを実行しています。動作していないようです。 は、だから私は、DEBUGを追加したい=スタート.But悪夢がこのエラー悪夢DEBUG on Google App Engine標準環境

Application startup error: 

のappengine-ハロー世界である私のpackage.json
"scripts": { "preinstall": "apt-get update && apt-get install -y libfontconfig1 libgtk2.0-0 libgconf-2-4 libasound2 libxtst6 libxss1 libnss3 xvfb && npm install nightmare", "deploy": "gcloud app deploy", "start": "xvfb-run -a node app.js", "lint": "samples lint", "pretest": "npm run lint", "system-test": "samples test app", "test": "npm run system-test", "e2e-test": "samples test deploy" }, "dependencies": { "express": "4.15.4", "nightmare": "2.10.0" }

ある

を失敗しています@ 0.0.1 start/app

xvfb-run -a DEBUG =ナイトメアノードapp.js
/usr/bin/xvfb-run:183:/ usr/bin/xvfb-run:DEBUG =ナイトメア:見つからない npm ERR!ファイルsh

答えて

0

Node.jsはAppEngine Standardではサポートされていません。だからあなたはFlex環境で動作しているかもしれません。 私はこの[1]で始まりました。 package.jsonの相違点を参照してください。 package.jsonをあなたのケースに合わせて修正し、app.jsでナイトメアを試しました。

私は、「スタート」 を置き換えることによって、あなたのケースを再現することができます:でpackage.jsonに、「XVFB・ラン-aノードapp.js」 を:

xvfb-run -a DEBUG=nightmare node app.js 

前のコマンドのヘルプページを示しています。私はDEBUGについては何も見ることができない

-a  --auto-servernum   try to get a free server number, starting at 
           --server-num 
-e FILE --error-file=FILE   file used to store xauth errors and Xvfb 
           output (default: /dev/null) 
-f FILE --auth-file=FILE   file used to store auth cookie 
           (default: ./.Xauthority) 
-h  --help     display this usage message and exit 
-n NUM --server-num=NUM   server number to use (default: 99) 
-l  --listen-tcp    enable TCP port listening in the X server 
-p PROTO --xauth-protocol=PROTO X authority protocol name to use 
           (default: xauth command's default) 
-s ARGS --server-args=ARGS  arguments (other than server number and 
           "-nolisten tcp") to pass to the Xvfb server 
           (default: "-screen 0 640x480x8") 

... だからあなたのような何かをしたい場合があります:

xvfb-run -e error.log -a node app.js 

エラーを保存するには、わかりません。

私の設定を共有します。

私は 'sudoのNPMがインストール' を実行する前に、あなたとそれを共有し、後:

私が追加:

"preinstall": "apt-get update && apt-get install -y libfontconfig1 libgtk2.0-0 libgconf-2-4 libasound2 libxtst6 libxss1 libnss3 xvfb && npm install nightmare", 

、変更: "スタート": "ノードapp.js"、 へ: "スタート": "XVFB・ラン-aノードapp.js" にファイルの自動更新を 'NPMインストール'

before: 
{ 
    "name": "appengine-hello-world", 
    "description": "Simple Hello World Node.js sample for Google App Engine Flexible Environment.", 
    "version": "0.0.1", 
    "private": true, 
    "license": "Apache-2.0", 
    "author": "Google Inc.", 
    "repository": { 
    "type": "git", 
    "url": "https://github.com/GoogleCloudPlatform/nodejs-docs-samples.git" 
    }, 
    "engines": { 
    "node": ">=4.3.2" 
    }, 
    "scripts": { 
    "preinstall": "apt-get update && apt-get install -y libfontconfig1 libgtk2.0-0 libgconf-2-4 libasound2 libxtst6 libxss1 libnss3 xvfb && npm install nightmare", 
    "deploy": "gcloud app deploy", 
    "start": "xvfb-run -a node app.js", 
    "lint": "samples lint", 
    "pretest": "npm run lint", 
    "system-test": "samples test app", 
    "test": "npm run system-test", 
    "e2e-test": "samples test deploy" 
    }, 
    "dependencies": { 
    "express": "4.15.4" 
    }, 
    "devDependencies": { 
    "@google-cloud/nodejs-repo-tools": "1.4.17" 
    }, 
    "cloud-repo-tools": { 
    "test": { 
     "app": { 
     "msg": "Hello, world!" 
     } 
    }, 
    "requiresKeyFile": true, 
    "requiresProjectId": true 
    } 
} 

後:

{ 
    "name": "appengine-hello-world", 
    "description": "Simple Hello World Node.js sample for Google App Engine Flexible Environment.", 
    "version": "0.0.1", 
    "private": true, 
    "license": "Apache-2.0", 
    "author": "Google Inc.", 
    "repository": { 
    "type": "git", 
    "url": "https://github.com/GoogleCloudPlatform/nodejs-docs-samples.git" 
    }, 
    "engines": { 
    "node": ">=4.3.2" 
    }, 
    "scripts": { 
    "preinstall": "apt-get update && apt-get install -y libfontconfig1 libgtk2.0-0 libgconf-2-4 libasound2 libxtst6 libxss1 libnss3 xvfb && npm install nightmare", 
    "deploy": "gcloud app deploy", 
    "start": "xvfb-run -a node app.js", 
    "lint": "samples lint", 
    "pretest": "npm run lint", 
    "system-test": "samples test app", 
    "test": "npm run system-test", 
    "e2e-test": "samples test deploy" 
    }, 
    "dependencies": { 
    "express": "4.15.4", 
    "nightmare": "^2.10.0" 
    }, 
    "devDependencies": { 
    "@google-cloud/nodejs-repo-tools": "1.4.17" 
    }, 
    "cloud-repo-tools": { 
    "test": { 
    "app": { 
     "msg": "Hello, world!" 
     } 
    }, 
    "requiresKeyFile": true, 
    "requiresProjectId": true 
    } 
} 

私は悪夢とスニペットのJSを共有しています:

'use strict'; 
// [START app] 
const express = require('express'); 
const app = express(); 
const Nightmare = require('nightmare') 
app.get('/', (req, res) => { 
    Nightmare({show: false}) 
    .goto('https://google.com') 
    .wait('body') 
    .insert('input[aria-label="Search"]', 'node-nightmare github.com') 
    .click('input[type="submit"]') 
    .wait(1000) 
    .wait('body') 
    .evaluate(function() { 
    // return $('a:contains("node-nightmare")').text(); 
    // res.status(200).send($('a:contains("node- 
nightmare")').text()).end(); 
    console.log('EVALUATE'); 
    }) 
    .then(function(ret) { 
    console.log('THEN'); 
    console.log(ret) 
    }); 
    res.status(200).send('Hello, world!!!!!').end(); 
}); 
// Start the server 
const PORT = process.env.PORT || 8080; 
app.listen(PORT,() => { 
    console.log(`App listening on port ${PORT}`); 
    console.log('Press Ctrl+C to quit.'); 
}); 
// [END app] 

あなたがして、ローカルサーバー上で実行することができます。 NPM を開始したり、 のgcloudアプリでのApp Engineに展開が

を展開それが役に立てば幸い!

[1] https://cloud.google.com/appengine/docs/flexible/nodejs/quickstart

関連する問題