WARNING: LoopBack connector "mongodb" is not installed - node.js

I m following a tutorial to create a react chat application with Loopback3 API but I m getting following Error when i try to run my application server ,I retried to install npm install loopback-connector-mongodb --save but still getting same issue. Do i need to install mongodb again? :-
WARNING: LoopBack connector "mongodb" is not installed as any of the following modules:
./connectors/mongodb
loopback-connector-mongodb
To fix, run:
npm install loopback-connector-mongodb --save
C:\Users\welcome\Desktop\ReactJS\chatServer\node_modules\loopback\lib\application.js:280
throw err;
^
Error: Cannot create data source "db":
WARNING: LoopBack connector "mongodb" is not installed as any of the following modules:
./connectors/mongodb
loopback-connector-mongodb
To fix, run:
npm install loopback-connector-mongodb --save
at DataSource.setup (C:\Users\welcome\Desktop\ReactJS\chatServer\node_modules\loopback-datasource-juggler\lib\datasource.js:457:26)
at new DataSource (C:\Users\welcome\Desktop\ReactJS\chatServer\node_modules\loopback-datasource-juggler\lib\datasource.js:138:8)
at Registry.createDataSource (C:\Users\welcome\Desktop\ReactJS\chatServer\node_modules\loopback\lib\registry.js:364:14)
at dataSourcesFromConfig (C:\Users\welcome\Desktop\ReactJS\chatServer\node_modules\loopback\lib\application.js:570:19)
at Function.app.dataSource (C:\Users\welcome\Desktop\ReactJS\chatServer\node_modules\loopback\lib\application.js:269:16)
at C:\Users\welcome\Desktop\ReactJS\chatServer\node_modules\loopback-boot\lib\executor.js:191:9
at C:\Users\welcome\Desktop\ReactJS\chatServer\node_modules\loopback-boot\lib\executor.js:282:5
at Array.forEach (<anonymous>)
at forEachKeyedObject (C:\Users\welcome\Desktop\ReactJS\chatServer\node_modules\loopback-boot\lib\executor.js:281:20)
at setupDataSources (C:\Users\welcome\Desktop\ReactJS\chatServer\node_modules\loopback-boot\lib\executor.js:181:3)
at execute (C:\Users\welcome\Desktop\ReactJS\chatServer\node_modules\loopback-boot\lib\executor.js:39:3)
at bootLoopBackApp (C:\Users\welcome\Desktop\ReactJS\chatServer\node_modules\loopback-boot\index.js:154:3)
at Object.<anonymous> (C:\Users\welcome\Desktop\ReactJS\chatServer\server\server.js:28:1)
at Module._compile (internal/modules/cjs/loader.js:1085:14)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
at Module.load (internal/modules/cjs/loader.js:950:32)
Emitted 'error' event on DataSource instance at:
at DataSource.setup (C:\Users\welcome\Desktop\ReactJS\chatServer\node_modules\loopback-datasource-juggler\lib\datasource.js:457:12)
at new DataSource (C:\Users\welcome\Desktop\ReactJS\chatServer\node_modules\loopback-datasource-juggler\lib\datasource.js:138:8)
[... lines matching original stack trace ...]
at Module.load (internal/modules/cjs/loader.js:950:32)
But Here is my package.json:-
{
"name": "chatServer",
"version": "1.0.0",
"main": "server/server.js",
"engines": {
"node": ">=6"
},
"scripts": {
"lint": "eslint .",
"start": "node .",
"posttest": "npm run lint"
},
"dependencies": {
"compression": "^1.0.3",
"cors": "^2.5.2",
"helmet": "^3.10.0",
"loopback": "^3.22.0",
"loopback-boot": "^2.6.5",
"loopback-component-explorer": "^6.2.0",
"loopback-connector-mongodb": "^6.0.1",
"serve-favicon": "^2.0.1",
"strong-error-handler": "^4.0.0",
"ws": "^7.5.3"
},
"devDependencies": {
"eslint": "^3.17.1",
"eslint-config-loopback": "^8.0.0"
},
"repository": {
"type": "",
"url": ""
},
"license": "UNLICENSED",
"description": "chatServer"
}
How do I deal with this?

Related

Issues with ES6 import/ from syntax

i have created an app which i am running it on my windows pc and works fine. is a MERN application now i have seted up a machine with ubuntu so i can serve it. but i cant run the back end i have the following error:
import mongoose from "mongoose"; ^^^^^^^^ SyntaxError: Unexpected identifier at Module._compile (internal/modules/cjs/loader.js:723:23) at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10) at Module.load (internal/modules/cjs/loader.js:653:32) at tryModuleLoad (internal/modules/cjs/loader.js:593:12) at Function.Module._load (internal/modules/cjs/loader.js:585:3) at Function.Module.runMain (internal/modules/cjs/loader.js:831:12) at startup (internal/bootstrap/node.js:283:19) at bootstrapNodeJSCore (internal/bootstrap/node.js:623:3)`
all node modules are installed,
node installed 10.19.0,
npm installed,
mongo db installed,
nodemodules installed,
"type":"module" is on json file:
{
"name": "myidea",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"serve": "npx nodemon index.js",
"seed": "node db/seeds.js"
},
"author": "",
"license": "ISC",
"dependencies": {
"bcrypt": "^5.1.0",
"body-parser": "^1.20.1",
"crypto-js": "^4.1.1",
"dotenv": "^16.0.3",
"express": "^4.18.2",
"gridfs-stream": "^1.1.1",
"jsonwebtoken": "^8.5.1",
"method-override": "^3.0.0",
"mongoose": "^6.6.5",
"mongoose-unique-validator": "^3.1.0",
"multer-gridfs-storage": "^5.0.2"
},
"type": "module"
}
But still when i do npm run serve or npm run seed i have the error above. what em i missing here?
i have tried npm run serve and npm run seed and still i am getting the same error despite the fact ii have added the "type":"module" on the json

Error on mac M1: Please install sqlite3 package manually

I was working on a technical test in node js, and I got this error "Please install sqlite3 package manually" when I ran npm start.
I searched for the answer on the internet for several days. I tried npm rebuild, npm i sqlite3, updating node, and some other things
I suspect it has something to do with my mac M1, I've encountered compatibility issues in the past, but I could be wrong.
I use node v16.14.2 and sqlite3 3.36.0.
Any help would be appreciated
Here is the full error:
Error: Please install sqlite3 package manually
at ConnectionManager._loadDialectModule (/Users/arthur/Documents/candidate-takehome/node_modules/sequelize/lib/dialects/abstract/connection-manager.js:55:15)
at new ConnectionManager (/Users/arthur/Documents/candidate-takehome/node_modules/sequelize/lib/dialects/sqlite/connection-manager.js:18:21)
at new SqliteDialect (/Users/arthur/Documents/candidate-takehome/node_modules/sequelize/lib/dialects/sqlite/index.js:13:30)
at new Sequelize (/Users/arthur/Documents/candidate-takehome/node_modules/sequelize/lib/sequelize.js:188:20)
at Object.<anonymous> (/Users/arthur/Documents/candidate-takehome/models/index.js:15:15)
at Module._compile (node:internal/modules/cjs/loader:1103:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1157:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:1005:19)
Here is my package json:
"name": "game-viewer-tool",
"version": "1.0.0",
"description": "Game Viewer Tool",
"main": "index.js",
"scripts": {
"start": "node index.js",
"eslint": "./node_modules/.bin/eslint .",
"test": "NODE_ENV=test node_modules/.bin/sequelize db:migrate; NODE_ENV=test ./node_modules/.bin/mocha --exit 'test/*.js'; rm ./database_test.sqlite3"
},
"license": "UNLICENSED",
"dependencies": {
"body-parser": "^1.19.0",
"express": "^4.17.1",
"sequelize": "^6.17.0",
"sequelize-cli": "^5.5.0",
"sqlite3": "^5.0.2"
},
"devDependencies": {
"chai": "^4.2.0",
"eslint": "^5.16.0",
"eslint-config-airbnb-base": "^13.1.0",
"eslint-plugin-import": "^2.16.0",
"eslint-plugin-vue": "^5.2.3",
"expect": "^24.8.0",
"husky": "^1.3.1",
"jest": "^23.6.0",
"lint-staged": "^8.1.5",
"mocha": "^6.1.4",
"nodemon": "^1.18.10",
"sinon": "^7.3.2",
"supertest": "^4.0.2"
}
}

when transpiling mocha test using ts-node i cannot find module 'tsconfig/register'

I have run both npm i ts-node and npm i ts-node --save-dev with no changes. ts-node works fine when I run it from the command line, but for some reason I cannot run mocha tests through test explorer. I get the error below:
error:
{ Error: Cannot find module 'tsconfig/register'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:581:15)
at Function.Module._load (internal/modules/cjs/loader.js:507:25)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:22:18)
at exports.requireOrImport (c:\Users\king\.vscode\extensions\hbenl.vscode-mocha-test-adapter-2.8.1\node_modules\mocha\lib\esm-utils.js:20:12)
at c:\Users\king\.vscode\extensions\hbenl.vscode-mocha-test-adapter-2.8.1\out\worker\bundle.js:5663:41
at Generator.next (<anonymous>)
at fulfilled (c:\Users\king\.vscode\extensions\hbenl.vscode-mocha-test-adapter-2.8.1\out\worker\bundle.js:90:58) code: 'MODULE_NOT_FOUND' }
package.json
{
"name": "appts",
"version": "1.1.1",
"description": "",
"main": "handler.js",
"scripts": {
"build:launchlocal": "cd serverless-site/ && npm start"
},
"mocha": {
"require": ["tsconfig/register"]
},
"author": "",
"license": "ISC",
"devDependencies": {
"#types/aws-lambda": "^8.10.40",
"#types/expect": "^24.3.0",
"#types/mocha": "^8.0.3",
"#types/validator": "^13.1.0",
"serverless-offline": "^5.12.1",
"serverless-plugin-typescript": "^1.1.9",
"serverless-s3-sync": "^1.10.4",
"serverless-step-functions": "^2.17.1",
"ts-mocha": "^7.0.0",
"ts-node": "^8.10.2"
},
"dependencies": {
.....omitted....
}
}
Turns out none of the package.json config options were working for me. I wound up implementing a .mocharc.json on the same level as my package.json which worked perfectly.
Example from this github repo (with more examples) copied here for posterity.
{
"extension": ["ts"],
"spec": "src/**/*.spec.ts",
"require": "ts-node/register"
}

How do you get express to work on Heroku app?

I have a app on Heroku and when I run node server.js it's throwing a error and saying Error: Cannot find module 'express'.
I've cleared the npm cache, rebuilt the app, checked the package.json & dependencies. Nothing much is working for me and I'm just looking for solutions now.
throw err;
^
Error: Cannot find module 'express'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:582:15)
at Function.Module._load (internal/modules/cjs/loader.js:508:25)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:22:18)
at Object.<anonymous> (/app/server.js:1:79)
at Module._compile (internal/modules/cjs/loader.js:701:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
at Module.load (internal/modules/cjs/loader.js:600:32)
at tryModuleLoad (internal/modules/cjs/loader.js:539:12)
at Function.Module._load (internal/modules/cjs/loader.js:531:3)
Trying to get the app to start.
Here's the package.json
{
"name": "SCOGEAgent",
"version": "0.0.0",
"description": "A simple Blockstack app",
"main": "index",
"scripts": {
"browserify": "browserify requires.js -o public/bundle.js",
"start": "run browserify & node server.js"
},
"repository": {
"type": "git",
"url": "git+https://github.com/blockstack/hello-blockstack.git"
},
"author": "",
"license": "MIT",
"bugs": {
"url": "https://github.com/blockstack/hello-blockstack/issues"
},
"homepage": "https://github.com/blockstack/hello-blockstack#readme",
"devDependencies": {
"browserify": "^14.1.0",
"express": "^4.16.4",
"opn": "^4.0.2"
},
"dependencies": {
"browserify": "^14.1.0",
"express": "^4.16.4",
"opn": "^4.0.2",
"#types/node": "^11.13.0",
"blockstack": "^18.0.4",
"express-ws": "^4.0.0",
"json-pointer": "^0.6.0",
"react-router-dom": "^5.0.0",
"socket.io": "^2.2.0",
"socket.io-client": "^2.2.0",
"websocket-stream": "^5.5.0"
}
}
Express should be in your dependencies not devDependencies. Here's how you know where to put your third-party dependencies.
Does the app need the dependency to run? Put it in dependencies
Does the app need the dependency to build, test, lint, or any other
task for development? Put it in devDependencies.
The only time this gets fuzzy is when you need to build the project before you run it. Then some of your build dependencies might be placed in dependencies instead of devDependencies. I'm sure there is a more professional way to manage this but that's how I do it.

Unexpected token ; Emberfire not installing with ember-cli

I have been breaking my head on installing emberfire to set up a backend and database for working with my front end ember app. I cleaned up node_modules, did a fresh npm install and also did npm cache clean. Gave up trying to fix it.
When i run,
$ ember install emberfire
i am getting below error.
Installed packages for tooling via npm.
Unexpected token ;
SyntaxError: Unexpected token ;
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 Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at Project.require (C:\Users\vignesh\Documents\Developer\MyTechStack\library-ember-app\node_modules\ember-cli\lib\models\project.js:285:12)
at Project.config (C:\Users\vignesh\Documents\Developer\MyTechStack\library-ember-app\node_modules\ember-cli\lib\models\project.js:201:26)
at CoreObject.extend.install (C:\Users\vignesh\Documents\Developer\MyTechStack\library-ember-app\node_modules\ember-cli\lib\models\blueprint.js:435:34)
Steps i tried till now
Cleaned the node_modules and did npm install again.
Installed ember-cli globally.
Cleared the cache.
My package.json looks like this
{
"name": "library-ember-app",
"version": "0.0.0",
"description": "Small description for library-ember-app goes here",
"private": true,
"directories": {
"doc": "doc",
"test": "tests"
},
"scripts": {
"build": "ember build",
"start": "ember server",
"test": "ember test"
},
"repository": "",
"engines": {
"node": ">= 0.10.0"
},
"author": "",
"license": "MIT",
"devDependencies": {
"broccoli-asset-rev": "^2.4.2",
"ember-ajax": "^2.0.1",
"ember-cli": "2.7.0",
"ember-cli-app-version": "^1.0.0",
"ember-cli-babel": "^5.1.6",
"ember-cli-bootstrap-sassy": "0.5.3",
"ember-cli-dependency-checker": "^1.2.0",
"ember-cli-htmlbars": "^1.0.3",
"ember-cli-htmlbars-inline-precompile": "^0.3.1",
"ember-cli-inject-live-reload": "^1.4.0",
"ember-cli-jshint": "^1.0.0",
"ember-cli-qunit": "^2.0.0",
"ember-cli-release": "^0.2.9",
"ember-cli-sass": "5.4.0",
"ember-cli-sri": "^2.1.0",
"ember-cli-test-loader": "^1.1.0",
"ember-cli-uglify": "^1.2.0",
"ember-data": "^2.7.0",
"ember-export-application-global": "^1.0.5",
"ember-load-initializers": "^0.5.1",
"ember-resolver": "^2.0.3",
"ember-welcome-page": "^1.0.1",
"emberfire": "2.0.1"
}
}
Bower.json
{
"name": "library-ember-app",
"dependencies": {
"ember": "~2.7.0",
"ember-cli-shims": "0.1.1",
"ember-qunit-notifications": "0.1.0",
"bootstrap-sass": "^3.3.7",
"firebase": "^3.0.0"
}
}

Resources