在节点中获取错误

时间:2017-01-05 06:08:45

标签: node.js

我是MEAN的新手,对自学node.js和express.js感兴趣。我已经安装了npm和相关的模块,但是我正在运行我的代码 我无法理解的错误消息。

我的代码如下:

var express = require('express');
var app express();
var myPort = 1117;

app.set('port', myPort);



app.get('/',

  function(req, res)
  {
    res.send(<h1>This is express!</h1>); 
    console.log("Express started at port no " + myPort);
  }

)

app.listen(myPort);

文件名是prj.js. 什么时候给命令节点prj.js 显示的错误如下:

G:\JavaPrgsJGD\Nodejs_My\prgs>node prj.js
G:\JavaPrgsJGD\Nodejs_My\prgs\prj.js:2
var app express();
    ^^^^^^^

SyntaxError: Unexpected identifier
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:373:25)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Function.Module.runMain (module.js:441:10)
at startup (node.js:139:18)
at node.js:974:3

1 个答案:

答案 0 :(得分:1)

It may be Syntax error in your migration files check you all migration fiels. for example: <?php use Illuminate\Support\Facades\Schema; use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; class CreateLikesTable extends Migration{ public function up() { Schema::create('likes', function (Blueprint $table) { $table->increments('id'); $table->string('name'); $table->string('status'); $table->rememberToken(); $table->timestamps(); }); } public function down() { Schema::drop('likes'); })'----->here is error of ending braces });---->>>here also its throughs an error so please check your braces in your migration files 无效的JavaScript。你的意思是var app express();