gpt4 book ai didi

javascript - repl Node js问题SyntaxError : Unexpected identifier

转载 作者:可可西里 更新时间:2023-11-01 10:46:01 26 4
gpt4 key购买 nike

https://repl.it/@doadhdoadh/IdleAccurateSource

const express        = require('express');
const MongoClient = require('mongodb').MongoClient;
const bodyParser = require('body-parser');
const app = express();
const port = 8000;
app.use(bodyParser.urlencoded({ extended: true }));
require('./app/routes')(app, {});
app.listen(port, () => {
console.log('We are live on ' + port);
});



node v9.7.1 linux/amd64
npm dev
evalmachine.<anonymous>:1
npm dev
^^^

SyntaxError: Unexpected identifier
at new Script (vm.js:51:7)
at createScript (vm.js:136:10)
at Object.runInContext (vm.js:181:10)
at evaluate (/run_dir/repl.js:133:14)
at ReadStream.<anonymous> (/run_dir/repl.js:116:5)
at ReadStream.emit (events.js:180:13)
at addChunk (_stream_readable.js:274:12)
at readableAddChunk (_stream_readable.js:261:11)
at ReadStream.Readable.push (_stream_readable.js:218:10)
at fs.read (fs.js:2124:12)

最佳答案

我查看了原始 server.js 文件,发现第 12 行缺少分号,即 db = database.db("api");

Update

我刚刚意识到 repl NodeJs 演示是使用 index.js 文件触发的。我刚刚在 server.js 中导出了一个函数并将其导入到 index.js 中以触发服务器创建过程。

检查 the updated poc

希望它有用!

关于javascript - repl Node js问题SyntaxError : Unexpected identifier,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52299130/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com