使用节点JavaScript的意外令牌ILLEGAL [英] Unexpected token ILLEGAL using node javascript
本文介绍了使用节点JavaScript的意外令牌ILLEGAL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用节点JavaScript执行命令,但是我的javascript中出现了未捕获的SyntaxError:意外令牌ILLEGAL".它位于第1行.
I am trying to execute a command using node JavaScript, but I am getting "Uncaught SyntaxError: Unexpected token ILLEGAL" in my javascript.Its on line 1.
var express = require('express');
var mongodb = require('mongodb');
var app = express();
var MongoClient = require('mongodb').MongoClient;
var db;
var port = process.env.PORT || 8080;
MongoClient.connect(mongo_host, function(err, database) {
if(err) throw err;
db = database;
app.listen(port, function () {
console.log('listening port' + port);
});
});
app.get('/', function (req, res) {
res.json({ message: 'Bienvenue Azure!' });
});
app.get('/plante', function (req, res) {
db.collection("plante").find().toArray(function(err, users) {
res.send(users);
});
});
注意:mongo_host是用于连接Azure的Git存储库URL
NB: mongo_host is the Git repository url to connect with azure
然后显示以下错误:
SyntaxError: Unexpected token ILLEGAL
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:404:25)
at Object.Module._extensions..js (module.js:432:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:313:12)
at Function.Module.runMain (module.js:457:10)
at startup (node.js:138:18)
at node.js:974:3
推荐答案
您的分号不是标准分号.它们是 \ u037e
(希腊问号).尝试将它们切换回标准分号,然后运行代码.
Your semicolons aren't standard semicolons. They are \u037e
(Greek Question Mark). Try switching them back to standard semicolons and then running the code.
有人一直在阅读 twitter .
这篇关于使用节点JavaScript的意外令牌ILLEGAL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文