GraphQL error when launching KeystoneJS application - mongodb

I just created a KeystoneJS using yarn create keystone-app my-app.
When I try to run it using yarn dev and browse to it I get the following error:
Error: Cannot use GraphQLSchema "[object GraphQLSchema]" from another module or realm.
Ensure that there is only one instance of "graphql" in the node_modules
directory. If different versions of "graphql" are the dependencies of other
relied on modules, use "resolutions" to ensure only one version is installed.
https://yarnpkg.com/en/docs/selective-version-resolutions
Duplicate "graphql" modules cannot be used at the same time since different
versions may have different capabilities and behavior. The data from one
version used in the function from another could produce confusing and
spurious results.
at instanceOf (/my/home/path/my-first-ks-app/node_modules/#keystonejs/keystone/node_modules/graphql/jsutils/instanceOf.js:28:13)
at isSchema (/my/home/path/my-first-ks-app/node_modules/#keystonejs/keystone/node_modules/graphql/type/schema.js:36:34)
at assertSchema (/my/home/path/my-first-ks-app/node_modules/#keystonejs/keystone/node_modules/graphql/type/schema.js:40:8)
at validateSchema (/my/home/path/my-first-ks-app/node_modules/#keystonejs/keystone/node_modules/graphql/type/validate.js:44:28)
at graphqlImpl (/my/home/path/my-first-ks-app/node_modules/#keystonejs/keystone/node_modules/graphql/graphql.js:79:62)
at /my/home/path/my-first-ks-app/node_modules/#keystonejs/keystone/node_modules/graphql/graphql.js:28:59
at new Promise (<anonymous>)
at graphql (/my/home/path/my-first-ks-app/node_modules/#keystonejs/keystone/node_modules/graphql/graphql.js:26:10)
at _graphQLQuery.<computed> (/my/home/path/my-first-ks-app/node_modules/#keystonejs/keystone/lib/Keystone/index.js:477:7)
at Keystone.executeQuery (/my/home/path/my-first-ks-app/node_modules/#keystonejs/keystone/lib/Keystone/index.js:252:14)
at Object.module.exports [as onConnect] (/my/home/path/my-first-ks-app/initial-data.js:10:22)
at /my/home/path/my-first-ks-app/node_modules/#keystonejs/keystone/lib/Keystone/index.js:323:35
at processTicksAndRejections (internal/process/task_queues.js:97:5)
at async executeDefaultServer (/my/home/path/my-first-ks-app/node_modules/#keystonejs/keystone/bin/utils.js:114:3)
error Command failed with exit code 1.
I am on Windows 10 / WSL (v1) with Ubuntu. KeystoneJS is running from Linux and MongoDB server is installed and running on Windows. This is because when I had it running in Linux, mongod showed as running and listening but I was not able to connect to it (via KeystoneJS or via shell using mongo command).
How do I fix this issue?

I was using graphql#15.0.0 when I got this error.
I fixed it by downgrading to graphql#14.6.0.
I got this issue on a keystone project with apollo.

run this line
rm -rf node_modules/#keystonejs/keystone/node_modules/graphql
or add it to the Dockerfile for building image for production

Related

Bootstrap failed: 5: Input/output error while running any service on macOS Big Sur version 11.5.2

I am trying to run mongodb-community#4.2 service using brew services start mongodb-community#4.2 (facing similar error, while running httpd service or any other service)
Following is the error:
Error: Failure while executing; /bin/launchctl bootstrap gui/502 /Users/chiragsingla/Library/LaunchAgents/homebrew.mxcl.mongodb-community#4.2.plist exited with 5.
There can be multiple reasons behind this error message. So, the first thing to do is to find where your mongo related logs are stored. To do that, run the following command -
sudo find / -name mongod.conf
This will get you the mongo db config file. On running this command, I got /usr/local/etc/mongod.conf. You may find it directly under /etc.
On opening mongod.conf, you will find log path mentioned there. You can open the file itself, or instead get the last 15-20 lines of this log file via tail command -
tail -n 15 <<your mongo db log path>>
Now, you will need to debug the issue mentioned in the logs. Generally, I have seen these three sets of issues -
Permission issue with /tmp/mongodb-27017.sock - While some SO answers asked to change the permissions for this file as a solution, my issue with this only went away after I removed this file.
Compatibility issue - If you see a message like Version incompatibility detected, it means that the mongodb version you have currently installed is different from the version whose data is present on your system. Uninstall the current mongodb version and then install the correct older version (if you don't want to lose the data).
Once you have done it, and your mongo is up and running, and you want to upgrade mongodb version, follow this SO answer.
Permission issues with WiredTiger - Using chmod to change file permissions resolved these.
In case you have any issue other than these three, you will still need to search more on SO and figure it out. Hope this was of some help! :)

compatibility error with create Strapi app with MongoDB

npm --v:
7.5.6
node -v
v15.9.0
npx create-strapi-app .
i am trying to create strapi app with MongoDB Atlas, but i get this error with i dont understand..
Connection test failed: Command failed: yarnpkg --cwd C:\Users\x\AppData\Local\Temp\strapic1eac7442b18 add strapi-connector-mongoose#3.5.3
error strapi-connector-mongoose#3.5.3:
The engine "node" is incompatible with this module.
Expected version >=10.16.0 <=14.x.x. Got 15.9.0
error Found incompatible module.
so: Expected version >=10.16.0 <=14.x.x. ??? of what? my node version?
is this is mean strapi is far behind with node?
how to solve this?
of what? my node version?
yes
is this is mean strapi is far behind with node? how to solve this?
use node with vesion between 10.16.0 and 14.x.x

What causes error "Connection test failed: spawn npm; ENOENT" when creating new Strapi project with MongoDB?

I am trying to create a new Strapi app on Ubuntu 16.4 using MongoDB. After stepping through the tutorial, here: https://strapi.io/documentation/3.0.0-beta.x/guides/databases.html#mongodb-installation, I get the following error: Connection test failed: spawn npm; ENOENT
The error seems obvious, but I'm having issues getting to the cause of it. I've installed latest version of MongoDB and have ensured it is running using service mongod status. I can also connect directly using nc, like below.
$ nc -zvv localhost 27017
Connection to localhost 27017 port [tcp/*] succeeded!
Here is an image of the terminal output:
Any help troubleshooting this would be appreciated! Does Strapi perhaps log setup errors somewhere, or is there a way to get verbose logging? Is it possible the connection error would be logged by MongoDB somewhere?
I was able to find the answer. The problem was with using npx instead of Yarn. Strapi documentation states that either should work, however, it is clear from my experience that there is a bug when using npx.
I switched to Yarn and the process proceeded as expected without error. Steps were otherwise exactly the same.
Update: There is also a typo in Strapi documentation for yarn. They include the word "new" before the project name, which will create a project called new and ignore the project name.
Strapi docs (incorrect):
yarn create strapi-app new my-project
Correct usage, based on my experience:
yarn create strapi-app my-project
The ENOENT error is "an abbreviation of Error NO ENTry (or Error NO ENTity), and can actually be used for more than files/directories."
Why does ENOENT mean "No such file or directory"?
Everything I've read on this points toward issues with environment variables and the process.env.PATH.
"NOTE: This error is almost always caused because the command does not exist, because the working directory does not exist, or from a windows-only bug."
How do I debug "Error: spawn ENOENT" on node.js?
If you take the function that Jiaji Zhou provides in the link above and paste it into the top of your config/functions/bootstrap.js file (above module.exports), it might give you a better idea of where the error is occurring, specifically it should tell you the command it ran. Then run the command > which nameOfCommand to see what file path it returns.
"miss-installed programs are the most common cause for a not found command. Refer to each command documentation if needed and install it." - laconbass (from the same link, below Jiaji Zhou's answer)
This is how I interpret all of the above and form a solution. Put that function in bootstrap.js, then take the command returned from the function and run > which nameOfCommand. Then in bootstrap.js (you can comment out the function), put console.log(process.env.PATH) which will return a string of all the directories your current environment is checking for executables. If the path returned from your which command isn't in your process.env.PATH, you can move the command into a path, or try re-installing.

Unexpected mongo exit code 100. Restarting

I was trying to run Meteor on my VPS and I was getting this error:
Unexpected mongo exit code 100. Restarting.
Unexpected mongo exit code 100. Restarting.
Unexpected mongo exit code 100. Restarting.
Can't start Mongo server.
MongoDB had an unspecified uncaught exception.
This can be caused by MongoDB being unable to write to a local database.
Check that you have permissions to write to .meteor/local. MongoDB does
not support filesystems like NFS that do not allow file locking.
I have figured out that the problem is in my user permissions or something like that. It works very smoothly when I try to run meteor with root access. If I try to run meteor with my "custom" user, it fails. Even though I grant him sudo privileges as listed on DigitalOcean. Why is it so? What is the problem behind?
I am on Ubuntu 14.04.1 LTS. Meteor is version 0.8.3 and I am using MongoDB coming with Meteor. I do not have seperated instalation of MongoDB.
Update: Basicly I have found the problem but I still do not now what is causing the problem. I am on DigitalOcean VPS. If I run Meteor over SSH, it fails. If I run Meteor on web Console Access, it works. I do not get it.
Answer https://stackoverflow.com/a/15752736 helped me to find out that Mongo doesn't want to start without properly set locale.
Try to run export LC_ALL="en_US.UTF-8" command before meteor command.
WARNING: This deletes the database and all of the application's data.
rm -rf .meteor/local
Solved it for me when none of the above solutions did.
I would guess that the custom user you created cannot remove the mongod.lock file due to insufficient premissions.
Also check that you have space on your HD, That was my problem.

Meteor without mongo

With 0.6.5 release it is possible to develop non web apps with meteor.
I rebuild it from scratch for ARM processor but I don't want DB support at all. (Mongo is a processor killer, has to high footprint and I simply don't need it)
ARM should work as DDP client only, with this in mind I build it manually without mongo.
And tried to build simplest app possible
only 1 package at start (all standard packages removed)
meteor
and one file in server folder
main = function(argv){
return "DAEMON"
}
Meteor.setInterval(function(){
console.log("HellOnWorld");
},1000);
On machine with full meteor install it works as expected
but without mongo installed I got errors
Unexpected mongo exit code 127. Restarting.
Unexpected mongo exit code 127. Restarting.
Initializing mongo database... this may take a moment.
Unexpected mongo exit code 127. Restarting.
Can't start mongod
Obviously I don't have and want mongo.
Is there any way to start meteor without waiting for mongo db ?
Meteor team plans to support other db's so it must be implemented sooner or later.
UPDATE
For newer versions of Meteor you need to remove the mongo package. The mongo package is embedded in the meteor-platform package. So you need to remove that and add all the rest back (from https://github.com/meteor/meteor/tree/devel/packages/meteor-platform):
meteor remove meteor-platform
meteor add meteor webapp logging tracker session ddp blaze spacebars templating check underscore jquery random ejson templating check underscore jquery random ejson
Then your app won't use Mongo anymore :).
In dev mode you can get rid of mongo by setting the MONGO_URL environment variable to something else and start meteor. For example: MONGO_URL=mongodb://nowhere meteor
Turns out that if you just set any MONGO_URL environment variable before running meteor, it won't start its local MongoDB! Fantastic for testing packages that don't depend on Mongo.
Before:
$ meteor test-packages ./
Testing fortawesome:fontawesome-compat...
[[[[[ Tests ]]]]]
=> Started proxy.
=> Started MongoDB.
=> Started your app.
=> App running at: http://localhost:3000/
After
$ MONGO_URL=mongodb://mysql.com meteor test-packages ./ # haha
Testing fortawesome:fontawesome-compat...
[[[[[ Tests ]]]]]
=> Started proxy.
=> Started your app.
=> App running at: http://localhost:3000/
Look ma, no Mongo!
I have confirmed that no mongo process is started, and no .meteor/local/db folder is created.
In Meteor 0.6.5, you can embed TingoDb, a Node.js implementation of the MongoDB API, with your Meteor bundle instead:
1) Go to the programs/server directory in your bundle and do npm install tingodb to add TingoDb to your bundle.
2) Near the top of programs/server/packages/mongo-livedata.js, with all of the other Npm.require statements, add the following line
var Db = Npm.require('tingodb')().Db;
3) In that same file (programs/server/packages/mongo-livedata.js) replace the following code block
MongoDB.connect(url, options, function(err, db) {
if (err)
throw err;
self.db = db;
Fiber(function () {
// drain queue of pending callbacks
_.each(self._connectCallbacks, function (c) {
c(db);
});
}).run();
});
with this code:
var db = new Db('path/to/your/db/directory', {});
self.db = db;
Fiber(function () {
_.each(self._connectCallbacks, function (c) {
c(db);
});
}).run();
The path/to/your/db/directory can be anywhere, but is relative to the programs/server directory in your bundle by default.
4) To run your Meteor bundle, it wants you to export an environment variable called MONGO_URL. You could dive in to the code and remove the checks for this, but since it's never used you can just as easily export a fake MONGO_URL, like the one in your bundle's README file:
export MONGO_URL='mongodb://user:password#host:port/databasename'
5) From your bundle's base directory run node main.js.
Caveat emptor: obviously you're messing around with Meteor internals here, and this will almost assuredly break with future versions.
Meteor 1.2.1 - Just set
MONGO_URL=none
for an environment variable. (none isn't a keyword, anything invalid appears to prevent mongo from starting)
As a weird possibility, make a mock mongo server on the right port, and set your environnmental variable to access it. I'd bet you only need a few handshake routines be implemented and no more traffic after that. Beyond my capability, but it does have the advantage of not needing to adopt to code changes as things shift.
The listed answers are not working with the Meteor 1.x.
Following is my way to run meteor without mongodb and doesn't need modify anything(neither source code nor packages configuration) in meteor.
git clone https://github.com/solderzzc/mongodb-fs
cd mongodb-fs && npm install && node samples/test-server.js
you will see following console log if everything goes well
meteor create --example leaderboard && cd leaderboard
MONGO_URL=mongodb://localhost:27027/fakedb meteor
Add point to the player, and check with the mongo command line:
mongo localhost:27027/fakedb