how to solve mongoParseError in nodeModule? - mongodb

this is output after run yarn start having this is the error:
`yarn run v1.22.17
warning ../../../package.json: No license field
$ ts-node index.ts
MongoParseError: Invalid scheme, expected connection string to start with "mongodb://" or "mongodb+srv://"
at new ConnectionString (/Users/youmnasalloum/Desktop/ts/user/node_modules/mongodb-connection-string-url/src/index.ts:133:13)
at parseOptions (/Users/youmnasalloum/Desktop/ts/user/node_modules/mongoose/node_modules/mongodb/src/connection_string.ts:253:15)
at new MongoClient (/Users/youmnasalloum/Desktop/ts/user/node_modules/mongoose/node_modules/mongodb/src/mongo_client.ts:337:34)
at /Users/youmnasalloum/Desktop/ts/user/node_modules/mongoose/lib/connection.js:783:16
at new Promise (<anonymous>)
at NativeConnection.Connection.openUri (/Users/youmnasalloum/Desktop/ts/user/node_modules/mongoose/lib/connection.js:780:19)
at Mongoose.createConnection (/Users/youmnasalloum/Desktop/ts/user/node_modules/mongoose/lib/index.js:285:10)
at Object.<anonymous> (/Users/youmnasalloum/Desktop/ts/user/db/index.ts:9:28)
at Module._compile (node:internal/modules/cjs/loader:1103:14)
at Module.m._compile (/Users/youmnasalloum/Desktop/ts/user/node_modules/ts-node/src/index.ts:1455:23)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
make: *** [start] Error 1`
this is package.json:
{ "name": "user", "version": "1.0.0", "main": "index.ts", "repository": "https://github.com/ArtistCrowdfundExchange/user", "author": "Oghogho Odemwingie", "license": "MIT", "devDependencies": { "#types/bcrypt": "^3.0.0", "#types/node": "^17.0.13", "typescript": "4.5.5" }, "scripts": { "start": "ts-node index.ts", "test": "echo no tests yet" }, "dependencies": { "#aws-sdk/client-s3": "^3.41.0", "#grpc/grpc-js": "^1.3.7", "amqp": "^0.2.7", "aws4": "^1.11.0", "bcrypt": "^5.0.0", "cuid": "^2.1.8", "encrypter": "^1.0.0", "erax.db": "^3.3.1", "jose": "3", "mongodb": "^4.5.0", "mongodb-uri": "^0.9.7", "mongoose": "6.1.8", "nanoid": "^3.1.29", "proto": "git+https://github.com/ArtistCrowdfundExchange/proto#playground", "ts-node": "^10.4.0", "winston": "^3.3.3", "yael-autoencrypt": "^1.1.0" } }
I tried to add packages mongo-Uri,mongo-connection-string-URI using yarn but still the same error when I do yarn start

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.

#sveltejs/adapter-cloudflare. I get many error while run `npm run build`

I'm Using #sveltejs/adapter-cloudflare to deploy my project to Cloudflare Pages.
I'm tried to use this package for a simple sveletKit app. It can success deploy to Pages.
But with more complex project, I got many many ERROR log while run build.
This is the log: https://pastebin.com/Yhw1Gu0c
And this is my package.json
"name": "app",
"version": "0.0.1",
"scripts": {
"dev": "vite dev --port 3331",
"build": "vite build",
"package": "svelte-kit package",
"preview": "vite preview",
"test": "playwright test",
"check": "svelte-check --tsconfig ./tsconfig.json",
"check:watch": "svelte-check --tsconfig ./tsconfig.json --watch",
"lint": "prettier --check --plugin-search-dir=. . && eslint .",
"format": "prettier --write --plugin-search-dir=. ."
},
"devDependencies": {
"#carbon/colors": "^11.3.0",
"#firebase/app-types": "^0.7.0",
"#playwright/test": "^1.22.2",
"#solana/qr-code-styling": "1.6.0-beta.0",
"#sveltejs/adapter-auto": "next",
"#sveltejs/adapter-cloudflare": "^1.0.0-next.31",
"#sveltejs/kit": "next",
"#typescript-eslint/eslint-plugin": "^5.27.0",
"#typescript-eslint/parser": "^5.27.0",
"bignumber.js": "^9.0.2",
"carbon-components-svelte": "^0.67.4",
"carbon-icons-svelte": "^11.2.0",
"carbon-preprocess-svelte": "^0.9.1",
"cookie": "^0.5.0",
"eslint": "^8.16.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-svelte3": "^4.0.0",
"firebase-admin": "^11.0.1",
"prettier": "^2.6.2",
"prettier-plugin-svelte": "^2.7.0",
"sass": "^1.54.0",
"svelte": "^3.44.0",
"svelte-check": "^2.7.1",
"svelte-preprocess": "^4.10.6",
"tslib": "^2.3.1",
"typescript": "^4.7.4",
"vite": "^3.0.0"
},
"type": "module",
"dependencies": {
"#solana/web3.js": "^1.50.1",
"firebase": "^9.9.1"
}
}

Error: Jest: Got error running globalSetup ../#shelf/jest-mongodb/setup.js, reason: Instance Exited before being ready and without throwing an error

I'm following the documentation on jestjs.io. When I try to run a test I get this error:
Error: Jest: Got error running globalSetup - /home/.../node_modules/#shelf/jest-mongodb/setup.js, reason: Instance Exited before being ready and without throwing an error!
This happened both when I've used typescript and also when I created a simple app using javascript instead:
package.json:
{
"name": "mongojest",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"devDependencies": {
"#shelf/jest-mongodb": "^3.0.1"
},
"scripts": {
"test": "jest"
},
"dependencies": {
"jest": "^28.1.0"
}
}
jest.config.js:
module.exports = {
coverageProvider: "v8",
"preset": "#shelf/jest-mongodb"
};
I haven't made any changes other than the minimum installs to get it running.
I got around this issue by installing Ubuntu 20.04. I was using the newer Ubuntu 22.04 and it seem to have caused some issues.
I installed typescript in my project. That was enough to run. Follow my configuration files
//package.json
{
"name": "research-with-programmers-api",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "jest --passWithNoTests --silent --noStackTrace --runInBand",
"test:verbose": "jest --passWithNoTests --runInBand",
"test:unit": "yarn test -- --watch -c jest-unit-config.ts",
"test:integration": "yarn test -- --watch -c jest-integration-config.ts",
"test:staged": "yarn test -- --findRelatedTest",
"test:ci": "yarn test -- --coverage"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"#shelf/jest-mongodb": "^4.1.0",
"#types/bcrypt": "^5.0.0",
"#types/jest": "^28.1.8",
"#types/mongodb": "^4.0.7",
"#types/node": "^18.7.13",
"#types/validator": "^13.7.6",
"#typescript-eslint/eslint-plugin": "^5.0.0",
"eslint": "^8.0.1",
"eslint-config-standard-with-typescript": "^22.0.0",
"eslint-plugin-import": "^2.25.2",
"eslint-plugin-n": "^15.0.0",
"eslint-plugin-promise": "^6.0.0",
"git-commit-msg-linter": "^4.1.3",
"husky": "^8.0.1",
"jest": "^29.0.1",
"lint-staged": "^13.0.3",
"ts-jest": "^28.0.8",
"ts-node": "^10.9.1",
"typescript": "^4.8.2"
},
"dependencies": {
"bcrypt": "^5.0.1",
"mongodb": "^4.10.0",
"validator": "^13.7.0"
}
}
//jest-config.ts
export default {
roots: ['<rootDir>/src'],
collectCoverageFrom: [
'<rootDir>/src/**/*.ts',
'!<rootDir>/src/**/protocols/*.ts',
'!<rootDir>/src/**/*protocols.ts',
'!<rootDir>/src/**/models/*.ts',
'!<rootDir>/src/**/usecases/*.ts',
'!<rootDir>/src/**/index.ts'
],
collectCoverage: true,
coverageDirectory: 'coverage',
coverageProvider: 'v8',
testEnvironment: 'node',
preset: '#shelf/jest-mongodb',
transform: {
'.+\\.ts$': 'ts-jest'
}
}
// jest-mongodb-config.ts
export default {
mongodbMemoryServerOptions: {
instance: {
dbName: 'jest'
},
binary: {
version: '4.0.3',
skipMD5: true
},
autoStart: false
}
}

facing error TS2339: Property 'then' does not exist on type 'StepDefinitions & Hooks'

facing error TS2339: Property 'then' does not exist on type 'StepDefinitions & Hooks'.
when I am trying to run tsc -w
tried all the solution which I know but nothing is working out.
Feature file:
Feature: Login creation for Amazon AWS
Scenario: Successful creation of Login
Given User navigate to Home Page
When User enter email and other details
Then Login is created sucessfully
Package.json
{
"name": "package.json",
"version": "1.0.0",
"description": "package",
"main": "index.js",
"dependencies": {
"#types/node": "^12.7.5"
},
"scripts": {
"test": "./node_modules/.bin/cucumber-js -p default"
},
"compilerOptions": {
"target": "es6"
},
"devDependencies": {
"#types/chai": "^4.2.2",
"#types/cucumber": "^4.0.7",
"chai": "^4.2.0",
"cucumber": "^5.1.0",
"cucumber-pretty": "^1.5.2",
"cucumber-tsflow": "^3.2.0",
"exceljs": "^2.0.1",
"protractor": "^5.4.2",
"protractor-cucumber-framework": "^6.1.3",
"ts-node": "^8.3.0",
"typescript": "^3.6.3",
"xlsx": "^0.15.1"
},
"author": "Bharani",
"license": "ISC"
}
Step Definition file:
import { Given, When, Then } from "cucumber"
Given("User navigate to Home Page", function(){
console.log("hafd");
});
When("User enter email and other details",function(){
console.log("dfhagsdf");
});
Then("Login is created sucessfully",function(){
console.log("dhfhd");
});
Package.json:
{
"name": "package.json",
"version": "1.0.0",
"description": "package",
"main": "index.js",
"dependencies": {
"#types/node": "^12.7.5"
},
"scripts": {
"test": "./node_modules/.bin/cucumber-js -p default"
},
"compilerOptions": {
"target": "es6"
},
"devDependencies": {
"#types/chai": "^4.2.2",
"#types/cucumber": "^4.0.7",
"chai": "^4.2.0",
"cucumber": "^5.1.0",
"cucumber-pretty": "^1.5.2",
"cucumber-tsflow": "^3.2.0",
"exceljs": "^2.0.1",
"protractor": "^5.4.2",
"protractor-cucumber-framework": "^6.1.3",
"ts-node": "^8.3.0",
"typescript": "^3.6.3",
"xlsx": "^0.15.1"
},
"author": "Bharani",
"license": "ISC"
}
Error in console:
'''[16:44:58] Starting compilation in watch mode...
POM_TS_CUCUMBER/Featurefile/stepdefinition/Steps.ts:3:32 - error
TS2339: Property 'then' does not exist on type 'StepDefinitions &
Hooks'.
3 defineSupportCode(({Given,When,then}) =>{
~~~~
[16:45:04] Found 1 error. Watching for file changes. '''
You have written Then in feature file which is not from the cucumber library. Try writing then statement again from cucumber library and try again.

Getting "connect ECONNREFUSED" error when I "npm run seed" in feathers api with mongodb

I'm learning react and feathers. For my recipes app that I've made in react I use feathers api and mongodb. I have some seeds as examples in /src/seeds.js and just began to set up everything in feathers but when I want to run my seeds(npm run seed) and check if it works on feathers localhost:3030/recipes I got this error:
Error creating user! { Error: connect ECONNREFUSED 127.0.0.1:3030
at Object.exports._errnoException (util.js:1022:11)
at exports._exceptionWithHostPort (util.js:1045:20)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1087:14)
code: 'ECONNREFUSED',
errno: 'ECONNREFUSED',
syscall: 'connect',
address: '127.0.0.1',
port: 3030,
response: undefined }
I don't know the error is because of connection or creating user!
I checked my mondo db, it runs.
this is package.json, just in case:
{
"name": "recipes-api(par)",
"description": "api for recipes app",
"version": "0.0.0",
"homepage": "",
"main": "src/",
"keywords": [
"feathers"
],
"license": "MIT",
"repository": {},
"author": {},
"contributors": [],
"bugs": {},
"engines": {
"node": ">= 0.12.0"
},
"scripts": {
"test": "npm run jshint && npm run mocha",
"jshint": "jshint src/. test/. --config",
"start": "node src/",
"mocha": "mocha test/ --recursive",
"seed": "node src/seeds.js"
},
"dependencies": {
"body-parser": "^1.17.1",
"compression": "^1.6.2",
"cors": "^2.8.3",
"feathers": "^2.1.1",
"feathers-authentication": "^0.7.12",
"feathers-client": "^2.2.0",
"feathers-configuration": "^0.3.3",
"feathers-errors": "^2.6.3",
"feathers-hooks": "^1.8.1",
"feathers-mongoose": "^3.6.2",
"feathers-rest": "^1.7.2",
"feathers-socketio": "^1.6.0",
"mongoose": "^4.9.6",
"passport": "^0.3.2",
"serve-favicon": "^2.4.2",
"superagent": "^3.5.2",
"winston": "^2.3.1"
},
"devDependencies": {
"jshint": "^2.9.4",
"mocha": "^3.3.0",
"request": "^2.81.0"
}
}
Before adding seeds I should have seen {"total":0,"limit":5,"skip":0,"data":[]} in http://localhost:3030/recipes that I'm still having it but after running seeds I should see the list of my recipes.
Anythings else that I need to copy here from my code? any idea?