How to use mongoose-double package - mongodb

I have mongoDB and mongoose library installed. Now if I want to use the mongoose-double package, does it require to be installed separately before? I want to store latitude and longitude data in double.
Below is my package.json file.
{
"version": "0.0.1",
"private": true,
"dependencies": {
"body-parser": "^1.19.0",
"cookie-parser": "^1.4.4",
"debug": "^4.1.1",
"express": "^4.17.1",
"jade": "^1.11.0",
"mongodb": "^3.3.2",
"mongoose": "^5.6.11",
"monk": "^7.0.0",
"morgan": "^1.9.1",
"request": "^2.88.0",
"serve-favicon": "^2.5.0"
}
}

Yes, you need to install the mongoose-double package before using that. You can install it using:
npm i mongoose-double
And then initialize your mongoose object like this:
var mongoose = require('mongoose')
require('mongoose-double')(mongoose);
Hope this works for you.

Related

Sanity Deployment on Vercel Issue: Cannot find module 'sanity' even though package is installed

So i'm trying to deploy sanity/nextjs on vercel. It runs fine locally but for the production build I keep getting the same error.
Here's the main error:
> build
> next build
info - Linting and checking validity of types...
Failed to compile.
./sanity/sanity.config.ts:1:28
Type error: Cannot find module 'sanity' or its corresponding type declarations.
> 1 | import {defineConfig} from 'sanity'
| ^
2 | import {deskTool} from 'sanity/desk'
3 | import {visionTool} from '#sanity/vision'
4 | import {schemaTypes} from './schemas'
Error: Command "npm run build" exited with 1
My sanity package.json:
{
"name": "nft-drop",
"private": true,
"version": "1.0.0",
"main": "package.json",
"license": "UNLICENSED",
"scripts": {
"dev": "sanity dev",
"start": "sanity start",
"build": "sanity build",
"deploy": "sanity deploy",
"deploy-graphql": "sanity graphql deploy"
},
"keywords": [
"sanity"
],
"dependencies": {
"#sanity/vision": "^3.0.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-is": "^18.2.0",
"sanity": "^3.0.0",
"styled-components": "^5.2.0"
},
"devDependencies": {
"#sanity/cli": "^3.2.3",
"#sanity/eslint-config-studio": "^2.0.1",
"eslint": "^8.6.0",
"prettier": "^2.8.3",
"typescript": "^4.0.0"
},
"prettier": {
"semi": false,
"printWidth": 100,
"bracketSpacing": false,
"singleQuote": true
}
}
My main folder package.json:
{
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start"
},
"dependencies": {
"#next/font": "^13.1.2",
"#sanity/image-url": "^1.0.1",
"#thirdweb-dev/react": "^3.6.9",
"#thirdweb-dev/sdk": "^3.6.9",
"ethers": "^5.7.2",
"next": "latest",
"next-sanity": "^4.0.6",
"react": "18.2.0",
"react-dom": "18.2.0"
},
"devDependencies": {
"#sanity/cli": "^3.2.3",
"#types/node": "18.11.3",
"#types/react": "18.0.21",
"#types/react-dom": "18.0.6",
"autoprefixer": "^10.4.12",
"postcss": "^8.4.18",
"tailwindcss": "^3.2.4",
"typescript": "4.9.4"
}
}
Thanks for your help.
I've checked that I have the 'sanity' package installed. I've added the recommended 'vercel.json' file and I also have the #sanity/cli installed. I've checked my local env setup to make sure that was also on vercel.
Maybe i've overinstalled the sanity packages in trying to solve it?
This is my first time using sanity, nextjs, and vercel so I've run out of ideas and haven't found the same issue answered elsewhere yet.
I had this issue as well, and it seems to be related to Sanity v3 which only came out a month ago - I rolled back to sanity v2 and it fixed the deployment issue
You can try to add .vercelignore in the root file and add sanity in there to ignore the whole folder
The fix is to move your sanity client config file (aka wherever you have your .env variables setup - in my case: sanity.ts) into a lib folder in the root directory. If the file itself is in the root directory, it will not build.
Updating the import statement from
import {defineConfig} from 'sanity'
to
import {defineConfig} from 'sanity/lib/exports'
worked for me.

Can't run vscode extension app in certain vscode versions

I created a vscode extension app and it works perfectly for some versions of vscode and not for others. So far, I've noticed this issue only in mac, but doesn't mean the same issue might happen for other versions of windows. In mac, when I try my extension app on version 1.40.2 it doesn't seem to work. There is no option to run my app in command palette or context menu. It's missing. But if I try it on version 1.55.2 (Universal) then the extension app appears and runs successfully in context menu and command palette no problem.
When I run it on my mac on version 1.40.2, I get the dialog message Extension is not compatible with Code 1.40.2. Extension requires: ^1.55.0.
Another error I've seen is in the console it come up with this error, which I created a new project by running yo code in that problem vscode version and hit F5 on a fresh template and I still got this error so not sure if it's related or not.
Error: Invalid problemMatcher reference: $ts-webpack-watch
Error: Invalid problemMatcher reference: $tslint-webpack-watch
I've also seen this error too
Why am I having a version compatibility issue? I don't think it's something in my extension.ts file because if I remove all my code ie
'use strict';
import * as vscode from 'vscode';
const ncp = require("copy-paste");
const os = require('os');
let folderOutput: string;
let fileOutput: vscode.Uri;
export function activate(context: vscode.ExtensionContext) {
let disposable = vscode.commands.registerCommand('my-app.startApp', async (uri: vscode.Uri) => {
});
context.subscriptions.push(disposable);
}
then the issue is still there so that eliminates that file from being the issue. I appreciate any help!
Package.json
{
"name": "my-app",
"displayName": "my app",
"description": "does something interesting",
"version": "0.0.1",
"engines": {
"vscode": "^1.55.0"
},
"categories": [
"Other"
],
"activationEvents": [
"onCommand:my-app.startApp"
],
"main": "./dist/extension.js",
"contributes": {
"commands": [
{
"command": "my-app.startApp",
"title": "Start My App"
}
],
"menus": {
"editor/context": [
{
"command": "my-app.startApp"
}
]
}
},
"scripts": {
"vscode:prepublish": "npm run package",
"compile": "webpack",
"watch": "webpack --watch",
"package": "webpack --mode production --devtool hidden-source-map",
"test-compile": "tsc -p ./",
"test-watch": "tsc -watch -p ./",
"pretest": "npm run test-compile && npm run lint",
"lint": "eslint src --ext ts",
"test": "node ./out/test/runTest.js"
},
"devDependencies": {
"#types/vscode": "^1.55.0",
"#types/glob": "^7.1.3",
"#types/mocha": "^8.0.4",
"#types/node": "^12.11.7",
"eslint": "^7.19.0",
"#typescript-eslint/eslint-plugin": "^4.14.1",
"#typescript-eslint/parser": "^4.14.1",
"glob": "^7.1.6",
"mocha": "^8.2.1",
"typescript": "^4.1.3",
"vscode-test": "^1.5.0",
"ts-loader": "^8.0.14",
"webpack": "^5.19.0",
"webpack-cli": "^4.4.0"
},
"dependencies": {
"copy-paste": "^1.3.0",
"simple-git": "^2.38.0"
}
}

Why protractor cucumber is not able to locate step file with latest version of Cucumber in Protractor Cucumber framework

I'm working with protractor cucumber framework and since from the long time i observed is cucumber is not able to find the spec file in the project. I have used the cucumber latest version 6.0.3 it is not able to find the spec file but same code i have run using the cucumber 1.3.3.. can any body tell me what's the difference with this versions? is there any thing i need to update for 6.0.3
Cucumber Dependency - 1.3.3
"cucumber": {
"version": "1.3.3",
"resolved": "https://registry.npmjs.org/cucumber/-/cucumber-1.3.3.tgz",
"integrity": "sha1-Za+2Xy+T9y2teN8qterPFGCf7C8=",
"requires": {
"camel-case": "^3.0.0",
"cli-table": "^0.3.1",
"co": "^4.6.0",
"colors": "^1.1.2",
"commander": "^2.9.0",
"duration": "^0.2.0",
"figures": "1.7.0",
"gherkin": "^4.1.0",
"glob": "^7.0.0",
"is-generator": "^1.0.2",
"lodash": "^4.0.0",
"stack-chain": "^1.3.5",
"stacktrace-js": "^1.3.0"
}
Cucumber Dependency 6.0.3 Latest
"cucumber": {
"version": "6.0.3",
"resolved": "https://registry.npmjs.org/cucumber/-/cucumber-6.0.3.tgz",
"integrity": "sha512-FSx7xdAQfFjcxp/iRBAuCFSXp2iJP1tF2Q5k/a67YgHiYbnwsD9F+UNv9ZG90LFHNsNQhb+67AmVxHkp4JRDpg==",
"dev": true,
"requires": {
"assertion-error-formatter": "^3.0.0",
"bluebird": "^3.4.1",
"cli-table3": "^0.5.1",
"colors": "^1.1.2",
"commander": "^3.0.1",
"cucumber-expressions": "^8.0.1",
"cucumber-tag-expressions": "^2.0.2",
"duration": "^0.2.1",
"escape-string-regexp": "^2.0.0",
"figures": "^3.0.0",
"gherkin": "5.0.0",
"glob": "^7.1.3",
"indent-string": "^4.0.0",
"is-generator": "^1.0.2",
"is-stream": "^2.0.0",
"knuth-shuffle-seeded": "^1.0.6",
"lodash": "^4.17.14",
"mz": "^2.4.0",
"progress": "^2.0.0",
"resolve": "^1.3.3",
"serialize-error": "^4.1.0",
"stack-chain": "^2.0.0",
"stacktrace-js": "^2.0.0",
"string-argv": "^0.3.0",
"title-case": "^2.1.1",
"util-arity": "^1.0.2",
"verror": "^1.9.0"
}
StepDef
module.exports=function(){
this.Given(/^Open the browser and Load the URL$/,async function(){
await firstBrowser.get(properties.get("url1"));
browser.logger.info("Title of the window is :"+await browser.getTitle());
//screenshots.takesScreenshot("filename");
});
this.When(/^User entered the text in the search box$/,async function(){
firstBrowser.sleep(3000);
await page1.email().sendKeys(testData.Login.CM[0].Username);
browser.sleep(3000);
await page1.password().sendKeys(testData.Login.CM[0].Password);
});
}
Config File
exports.config = {
//seleniumAddress: 'http://localhost:4444/wd/hub',
getPageTimeout: 60000,
allScriptsTimeout: 500000,
directConnect:true,
framework: 'custom',
// path relative to the current config file
frameworkPath: require.resolve('protractor-cucumber-framework'),
capabilities: {
'browserName': 'chrome'
},
ignoreUncaughtExceptions:true,
// Spec patterns are relative to this directory.
specs: [
'H:\\workspace\\Protractor_Cucumber\\src\\FeatureFiles\\Test.feature'
],
cucumberOpts: {
require: 'H:\\workspace\\Protractor_Cucumber\\src\\StepDefFiles\\*.js',
tags: false,
profile: false,
'no-source': true
},
onPrepare: function () {
browser.waitForAngularEnabled(false);
const {Given, Then, When, Before} = require('cucumber');
}
};
i didn't used any cucumber hooks in my test scripts..
What makes them to work different, can some help in this?
One reason is Then/When/Given usage change in cucumber 6.x, you can change few step functions to verify this.
For 1.x step function file looks like
module.exports = function () {
this.Then(/^Then the response status is (.*)$/, function (status) {
assert.equal(this.responseStatus, status)
});
this.When(//, ...)
}
For 6.x step function file looks like
const { Then, When } = require('cucumber');
Then(/^the response status is (.*)$/, function (status) {
assert.equal(this.responseStatus, status)
});
When(//,...)
Another possible reason is need to upgrade protractor-cucumber-framework version which is compatible with the cucumber#6.x

Heroku push rejected failed: npm ERR! 404 Not Found: event-stream#3.3.6. This causes a build fail

I am getting the error:
Heroku push rejected failed to define node.js node not defined in package.json
My app works locally, this is an Express MongoDB using handlebars. My gitignore has node_modules in it and the strange part is I am using nodemon and not node.
package.json:
{
"name": "Jukebox",
"version": "1.1.0",
"engines": {
"node": "11.3.0",
"npm": "6.4.1"
},
"private": true,
"scripts": {
"start": "node ./bin/www",
"dev": "nodemon ./bin/www"
},
"dependencies": {
"cookie-parser": "~1.4.3",
"debug": "~2.6.9",
"dotenv": "^6.1.0",
"express": "~4.16.0",
"hbs": "~4.0.1",
"http-errors": "~1.6.2",
"method-override": "^3.0.0",
"mongoose": "^5.3.6",
"morgan": "~1.9.0",
"nodemon": "^1.18.4"
},
"description": "Jukebox is an app where users can add their favorite songs for others to discover. There will be a maximum number of 32 songs that can be added. When user selects genre the artists of that genre will populate the grid and a button will appear to add artist.",
"main": "app.js",
"repository": {
"type": "git",
"url": "git+https://github.com/chuckderosier/Jukebox.git"
},
"author": "",
"license": "ISC",
"bugs": {
"url": "https://github.com/chuckderosier/Jukebox/issues"
},
"homepage": "https://github.com/chuckderosier/Jukebox#readme"
}
You need to specify a Node.js version within your package.json that matches
the runtime you’re developing and testing with.
Do the following:
Within your cmd line type: node --version and see what version of Node you're developing with.
Add an engines section within your package.json specifying your node version from step 1. For example something similar to this:
"engines": {
"node": "10.3.0"
}
For more information checkout the Heroku documentation for Nodejs buildpacks

DefinitelyTyped Typescript Definition doesn't recognize mongoose dependencies

I'm using TypeScript, Angular 2 and mongoose. I installed mongoose using NPM:
"dependencies": {
"#angular/common": "2.0.0-rc.6",
"#angular/compiler": "2.0.0-rc.6",
"#angular/core": "2.0.0-rc.6",
"#angular/forms": "2.0.0-rc.6",
"#angular/http": "2.0.0-rc.6",
"#angular/platform-browser": "2.0.0-rc.6",
"#angular/platform-browser-dynamic": "2.0.0-rc.6",
"#angular/router": "3.0.0-rc.2",
"#angular/upgrade": "2.0.0-rc.6",
"body-parser": "^1.15.2",
"bootstrap": "^3.3.6",
"core-js": "^2.4.1",
"express": "^4.13.4",
"jquery": "^3.1.0",
"mongoose": "^4.6.0",
"morgan": "^1.7.0",
"path": "^0.12.7",
"reflect-metadata": "^0.1.3",
"rxjs": "5.0.0-beta.11",
"systemjs": "0.19.27",
"typescript": "^2.0.0",
"typings": "^1.3.2",
"zone.js": "^0.6.17"
},
"devDependencies": {
"jasmine-core": "^2.5.1",
"karma": "^1.2.0",
"karma-chrome-launcher": "^2.0.0",
"karma-cli": "^1.0.1",
"karma-firefox-launcher": "^1.0.0",
"karma-jasmine": "^1.0.2"
}
Of course, mongoose installs mongodb as a dependency. I then installed the mongoose DefintielyTyped definitions using command typipngs install dt~mongoose --global --save. That installs the mongoose index file:
// Generated by typings
// Source: https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/51c51f03549a63f8791865bf26480947e22f4902/mongoose/mongoose.d.ts
declare module "mongoose" {
import events = require('events');
import mongodb = require('mongodb');
import stream = require('stream');
import mongoose = require('mongoose');
etc., etc. When I run tsc, I get the following error: typings/globals/mongoose/index.d.ts(5,28): error TS2307: Cannot find module 'mongodb'. It doesn't feel right to npm install mongodb --save since it is already installed with mongoose.
What is the right way of fixing this?
It's not asking you to install the module, it's asking you to install the typings for mongodb. Typings by default do not install dependency typings. So you have to go through and install each dependencies manually.
Specifically for Mongoose, you are going to need the typings for mongodb, mpromise and mongoose-promise (I think that's all of them).