私はOK 200と呼ばれるChromeアプリケーションを使用しています/Google Chromeをnode.jsサーバーとして使用するにはどうすればよいですか?
<html>
<head>
<script>
var http = require("http");
http.createServer(function (request, response) {
// Send the HTTP header
// HTTP Status: 200 : OK
// Content Type: text/plain
response.writeHead(200, {'Content-Type': 'text/plain'});
// Send the response body as "Hello World"
response.end('Hello World\n');
}).listen(8081);
// Console will print the message
console.log('Server running at http://127.0.0.1:8081/');
</script>
</head>
</html>
HTMLファイルにノードのjsのHello Worldの例を貼り付けコピー!このページをご利用いただけるサーバーhttp://127.0.0.1:8887/ Google Chromebookで理想的なソリューションが動作します。
私はこれを実行すると、それはエラーを与える:
Uncaught ReferenceError: require is not defined(…)
だから、ノードに固有のいくつかの機能は、Chromeで埋め込まれることはありません意味します。これらの機能を利用できるようにする拡張機能、Chromeアプリケーション、またはネイティブクライアントアプリケーションはありますか?まだChromeに組み込まれているv8エンジンを活用していますか?
プレーンなChromeブラウザではありません。標準のブラウザは、あらゆる種類のサーバを実行する機能を持っておらず、残りのnode.js機能にはほとんどアクセスしません。サーバーの作成を可能にするために必要な機能を追加できる素朴なコード(別のアプリまたはプラグイン)が必要になります。 – jfriend00
https://github.com/kzahel/web-server-chrome – guest271314
このプロセスはhttps://www.chromium.org/developers/design-documents/sync、http://stackoverflow.com/questions/で行う必要があります。 2162173/is-google-chrome-embeddable、http://stackoverflow.com/questions/35899536/method-for-streaming-data-from-browser-to-server-via-http chromium https://www.chromium.org/developers/testing/chromium-build-infrastructureの独自のバージョンを構築することもできます。 – guest271314