お世話になります。Macをアップグレードして再度MongoDBをインストールして接続をしました
今学習しなおしているのは下記です
https://dotinstall.com/lessons/basic_nodejs/26215
環境は
centos6.8
node -v
v9.2.1
mongo --version
MongoDB shell version v3.6.0
npm -v
5.5.1
[vagrant@localhost nodejs]$ mongo --version
MongoDB shell version v3.6.0
git version: a57d8e71e6998a2d0afde7edc11bd23e5661c915
OpenSSL version: OpenSSL 1.0.1e-fips 11 Feb 2013
allocator: tcmalloc
modules: none
build environment:
distmod: rhel62
distarch: x86_64
target_arch: x86_64
[vagrant@localhost nodejs]$ node mongo.js
/home/vagrant/nodejs/node_modules/mongodb/node_modules/mongodb-core/lib/topologies/read_preference.js:43
const ReadPreference = function(mode, tags, options) {
^^^^^
SyntaxError: Use of const in strict mode.
at Module._compile (module.js:439:25)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (/home/vagrant/nodejs/node_modules/mongodb/node_modules/mongodb-core/lib/wireprotocol/shared.js:3:22)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
mongo.js
var MongoClient = require('mongodb').MongoClient, settings = require('./settings'); MongoClient.connect("mongodb://"localhost/"+settings.db, function(err, db) { if (err) { return console.dir(err); } console.log("connected to db"); });
const???エラーの原因をどのように対処すればいいですか?
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2017/12/21 06:41