Why am I getting a 500 response when using Deno and MongoDB? - mongodb

I have the following code...
// test.mjs
import {MongoClient} from "https://dev.jspm.io/mongodb";
console.log("Loaded");
But when I run deno run ./test.mjs I get...
Download https://dev.jspm.io/npm:require_optional#1.0.1/index.dew.js
error: Import 'https://dev.jspm.io/npm:require_optional#1.0.1/index.dew.js' failed: 500 Internal Server Error
at https://dev.jspm.io/npm:require_optional#1?dew:1:0
What I am missing? I am using ChromeOs so basically Linux.

Related

Sails fails to lift - Server failed to start (sailsjs, mongodb, nodemon sails lift --redis)

In VSCode When I run the sails lift sometimes it works, but when I tried "nodemon sails lift --redis" it shows this message.
enter image description here
error: Server failed to start.
error: (received error: EACCES)
error:
error: Troubleshooting tips:
error:
error: -> Do you have a slow Grunt task, or lots of assets?
error:
error: -> Is something else already running on port 1337 ?
error:
error: -> Are you deploying on a platform that requires an explicit hostname, like OpenShift?
error: (Try setting the explicitHost config to the hostname where the server will be accessible.)
error: (e.g. mydomain.com or 183.24.244.42)
Then Sails lift also showing the same error.
I'm using windows 11.
sail -v = 1.5.3
node -v = v16.15.1
MongoDB shell version v4.0.28
Ubuntu windows app(Ubuntu 22.04.1 LTS release)

Script fails at import Gtk

I've spent some time looking into this and I can't seem to find anyone else with this issue which leads me to believe that I may just be stupid...
I have a few python scripts that attempt to use Gtk to create windows and they fail with the error message "Unable to init server: Could not connect: Connection refused". I've tracked this down to Gtk because I get the same error with the following script:
import gi
gi.require_version("Gtk","3.0")
from gi.repository import Gtk
Any and all help would be very much appreciated.

Pyspark running error

The Spark I connected to, is not built on my local computer but a remote one. Everytime when I connect to it http://xx.xxx.xxx.xxx:10000/, the error says:
[IPKernelApp] WARNING | Unknown error in handling PYTHONSTARTUP file /usr/local/spark/python/pyspark/shell.py:
18/03/07 08:52:53 WARN ObjectStore: Failed to get database global_temp, returning NoSuchObjectException
Anyways, I still keep trying to run it on Jupyter notebook:
from pyspark.conf import SparkConf
SparkSession.builder.config(conf=SparkConf())
dir(spark)
When I ran it yesterday, it shows directory. when I did it today, it says:
NameError: name 'spark' is not defined
Any suggestion is appreciated!
you re missing the spark variable
from pyspark.conf import SparkConf
spark=SparkSession.builder.config(conf=SparkConf())
dir(spark)

DocPad plugin: odd errors when testing, hangs when including in project

I'm trying to write a DocPad plugin to import MongoDB docs into the DocPad database for use in a static website. The source code is at https://github.com/nfriedly/docpad-plugin-mongodb and it's based on https://github.com/docpad/docpad-plugin-tumblr
When I run cake test, I get this output:
cake compile
cake install
npm install (for app)
npm install (for test)
npm install (for docpad tests)
coffee compile
npm test
> docpad-plugin-mongodb#2.0.0 test c:\Users\IBM_ADMIN\docpad-plugin-mongodb
> npm run prepare_test_db && node ./out/mongodb.test.js
> docpad-plugin-mongodb#2.0.0 prepare_test_db c:\Users\IBM_ADMIN\docpad-plugin-mongodb
> mongo test/prepare_database.mongo.js
MongoDB shell version: 2.6.5
connecting to: test
connecting to: docpad_plugin_mongodb_test
mongodb
mongodb > create
notice: If everyone who saw this message donated $1/week, maintaining DocPad would become sustainable: http://docpad.org/donate
error: An error occured:
Error: Didn't place the skeleton as the desired structure already exists
at c:\Users\IBM_ADMIN\docpad-plugin-mongodb\node_modules\docpad\out\lib\docpad.js:4107:17
at Object.cb [as oncomplete] (fs.js:168:19)
error: To report the above error, follow the guide at: http://docpad.org/bug-report
mongodb > create OK
mongodb > load plugin mongodb
mongodb > load plugin mongodb OK
mongodb > generate
mongodb > generate > action
warning: You have multiple files being written to c:\Users\IBM_ADMIN\docpad-plugin-mongodb\test\out\testData\1.json, they are:
- testData/1.json:c7
- testData/1.json:c5
Rename one of them to avoid an over-write
FAILURE: 2/3 tests ran successfully; 0 failed, 1 incomplete, 0 errors
npm ERR! Test failed. See above for more details.
npm ERR! not ok code 0
c:\Users\IBM_ADMIN\docpad-plugin-mongodb\Cakefile:99
throw err;
^
Error: Process exited with error status code
at ChildProcess.<anonymous> (c:\Users\IBM_ADMIN\docpad-plugin-mongodb\Cakefile:88:15)
at ChildProcess.emit (events.js:98:17)
at maybeClose (child_process.js:756:16)
at Process.ChildProcess._handle.onexit (child_process.js:823:5)
And, when I include the module in my project, it just hangs after this:
$ docpad run
info: Welcome to DocPad v6.69.1 (local installation: c:\Users\IBM_ADMIN\watson-developer-cloud\node_modules\docpad
notice: If everyone who saw this message donated $1/week, maintaining DocPad would become sustainable: http://docp
info: Contribute: http://docpad.org/docs/contribute
info: Plugins: eco, mongodb
info: Environment: development
info: DocPad listening to http://0.0.0.0:9778/ on directory c:\Users\IBM_ADMIN\watson-developer-cloud\out
(And if I visit localhost:9778, it just hangs and never loads a page)
It seems like it only displays logs from plugins after the first pass is complete, so I started adding throw statements to see what it was doing. It seems that it imports things from mongo successfully, and it creates the document, but when the plugin calls document.action 'load', (err) ->, that callback is never fired.
Can anyone provide some guidance on what I'm messing up and how to get things working smoothly?
Fixed it. The TaskGroup library (apparently) once had a .once('complete', callback) event that no longer works. Switching it to .done(callback) (and fixing a couple of other small bugs) got me working now.
It still gives me the "Error: Didn't place the skeleton as the desired structure already exists" but the tests all pass now, so I'll call it a win.

PHP Fatal error: Class 'MongoDate' not found

I use lithium console (lithium/console/li3) to run some command and I get this error:
PHP Fatal error: Class 'MongoDate' not found
My system details:
mongodb server: 2.6.1
php mongodb client: 1.5.2
apache 2.4.7
php 5.5.9-1ubuntu4
$Requests = Requests::find('all', array('conditions'=>array(
'expired'=>array('<'=>new \MongoDate(time())),
'processed'=>0
)));
I don't have this error while running this code in older version system
PHP Version 5.3.10-1ubuntu3.11
Apache/2.2.22 (Ubuntu) Server
mongodb client: 1.4.5
mongodb server: 2.4.10
Thank you.
One more thing: I try to create just a simple script
$date = new MongoDate();
it runs without problem via webserver (browser) but if I use php command to run this file, I get the same error: Class 'MongoDate' not found
So I believe that it's php command problem.
For people that have come here using PHP7, the classs has been renamed:
MongoDate is now MongoDB\BSON\UTCDateTime
Also I've found that this now wants miliseconds instead of seconds, so make sure you multiple your input by 1000, for example:
$date = new \MongoDB\BSON\UTCDateTime(strtotime('yesterday') * 1000);
Make sure your mongodb extension is loaded.
var_dump(extension_loaded('mongodb'));
If not, you must load it in php.ini.