Importing "gitlab" package from MeteorJS returns empty object - meteor

I've installed gitlab in my Meteor project with meteor npm install --save gitlab and imported the package in the imports/api/foo.js file with all the following variations (the comment on the front is the log of the Gitlab object):
import Gitlab from 'gitlab'; // {}
import * as Gitlab from 'gitlab'; // { default: {}, [Symbol(__esModule)]: true }
import { Gitlab } from 'gitlab'; // undefined
const Gitlab = require('gitlab'); // {}
const Gitlab = require('gitlab/dist/es5'); // {}
const Gitlab = require('gitlab/dist/latest'); // {}
If I run just console.log(require('gitlab')) with NodeJS, I get the correct result.
How am I supposed to import 'gitlab' from a meteor application?

I tried to reproduce the issue with a clean Meteor 1.8.0.2 project and it is working fine for me:
/server/main.js:
import Gitlab from 'gitlab'
Meteor.startup(() => {
console.log(Gitlab) // [Function: Bundle]
const api = new Gitlab({
url: 'http://example.com', // Defaults to https://gitlab.com
token: 'abcdefghij123456' // Can be created in your profile.
})
console.log(api) // full API as in documentation
})
So what options do you have here?
Make sure you use gitlab on the server
Check the node_modules folder, whether it is really installed there.
Try to reset your project using meteor reset and then start again so all node_modules a rebuild and all Meteor packages are rebuild and the local dev build is rebuild. This will often fix things.
Create a fresh project and start to reproduce the issue step by step, starting from my working example and change the file structure stepwise to the structure of your project.

Related

SvelteKit build is working fine locally but on vercel it blews up?

I am trying out the SvelteKit framework and playing with it. I build a dummy page and don't have any issue with the dev command and the build command finding components and sections. However, when I try to deploy it on the Vercel, Vite seems to be having trouble finding components.
[vite:load-fallback] Could not load
/vercel/path0/src/sections/About.svelte (imported by
src/routes/index.svelte): ENOENT: no such file or directory, open
'/vercel/path0/src/sections/About.svelte'
This is the config file I set up module alias and Vercel adapter.
import vercel from '#sveltejs/adapter-vercel';
import { resolve } from 'path';
/** #type {import('#sveltejs/kit').Config} */
const config = {
kit: {
// adapter: adapter(),
adapter: vercel(),
vite: {
resolve: {
alias: {
$src: resolve('./src'),
$components: resolve('./src/components'),
$sections: resolve('./src/sections')
}
}
}
}
};
export default config;
By default, Vercel CLI detecting output directory to be public but I overrode it by vercel_build_output. I also tried with auto adapter resulted in same issue. I tried deployment using github repo directly and with vercel cli too encountered the same issue. I tried it without alias too giving relative import like ../components resulted in same issue their too.
You're filenames is Sidebar.svelte with a lowercase b while when you try to import it, it's SideBar.svelte with capital B

Firebase Hosting: Function not working with ServerMiddleware (Vue/ Nuxt)

I am building a project that utilises ServerMiddleware to render some pages client side only (I can't find another way of getting this working well without ServerMiddleware. Problems on refreshing pages and so on...)
The problem: Unfortunately every time I try and deploy to my Firebase Function through 'firebase deploy' I get an error:
Error: Cannot find module '~/serverMiddleware/selectiveSSR.js'
The function builds OK if I exclude the following line. Nuxt/ Vue is not including ~/serverMiddleware/ as part of its build as far as I can see.
Here is the code in nuxt.config.js to reference my serverMiddleware:
serverMiddleware: ['~/serverMiddleware/selectiveSSR.js']
Adding either the directory or path (as above) to the file itself within Build in nuxt.config.js does not help either. Maybe I am doing it wrong?
Everything works perfectly when testing (Not building) locally.
Any ideas on how I can resolve this please?
Thanks!
Ok so for anyone else who hits this, here is how I got around it.
Firstly, I don't know if this is the fault of Firebase Hosting or Nuxt (I would guess Nuxt but I stand to be corrected), but here is what to do....
1) Remove any reference to ServerMiddleware from nuxt.config.js
2) Add the following to nuxt.config.js
modules: [
'~/local-modules/your-module-name'
],
3) Create directory ~/local-modules/your-module-name in your project root
4) In the new directory, create a package.json:
{
"name": "your-module-name",
"version": "1.0.0"
}
and index.js - key thing, this.addServerMiddleware allows you to call middleware server-side
module.exports = function(moduleOptions) {
this.addServerMiddleware('~/serverMiddleware/')
}
5) Create directory ~/serverMiddleware
6) Add your middleware function to index.js in the new directory:
export default function(req, res, next) {
// YOUR CODE
next() // Always end with next()!
}
7) Update package.json with your new local module under "dependencies":
"your-module-name": "file:./local-modules/your-module-name"
Don't forget you need to do this within the functions directory too or Firebase will complain it can't find your new module

ASP.NET Core and Angular - SSR

...and it's not working. :(
I create ASP.NET Core app from angular template. I actualy followed these directions from these official ssr docs
Setting up ASPNETCORE_Environment variable
Run dotnet new angular
Modify Startup.cs and add UseSpaPrerendering
Add settings to .angular-cli.json
Add tsconfig.server.json
Add app.server.module.ts
Add main.server.ts
Modify csproj BuildServerSideRenderer option
Run npm i in ClientApp directory
In Development it's work fine. But after production build it work's like in development, ssr not working. Angular continues to run on client.
My steps to build:
Run dotnet build -c Release -o out
Angular builds without errors (after build in out dir, creates 2 angular builds - dist and dist-server (dist-server size is 32Kb)
Run dotnet ssr.dll
These basic steps for SSR. But I modify main.ts and main.server.ts files, add these to extraProviders
for main.ts
{ provide: 'OS', useValue: 'Client' }
for main.server.ts
{ provide: 'OS', useValue: 'Server' }
and modify home component
import { Component, Inject } from '#angular/core';
#Component({
selector: 'app-home',
templateUrl: './home.component.html',
})
export class HomeComponent {
os: string = null;
constructor(#Inject('OS') public osinject: string) {
console.log(osinject);
this.os = osinject;
}
}
Actualy after build and run my project, i should have seen 'Hello Server', but i see 'Hello Client'.
I tried create 2 times from scratch, tried run in docker container, tried run other projects with ssr (find in github). But it all not working for me
> dotnet --version
2.1.403
> node --version
v8.11.3
Whats went wrong guys?
Here my repo (just in case)

Error with Firebase on Electron app: Failed to load gRPC

I'm building an Electron app, and in the renderer.js file, I'm using Firebase Admin to get Firestore data. However, whenever I run it, it returns this error in the logs..
Error: Failed to load gRPC binary module because it was not installed for the current system
Expected directory: electron-v2.0-darwin-x64-unknown
Found: [node-v48-darwin-x64-unknown]
This problem can often be fixed by running "npm rebuild" on the current system
I tried to run "npm rebuild", but it still didn't fix it.
I also tried updating Firebase Admin and gRPC.
Here is the code from the renderer.js file...
// This file is required by the index.html file and will
// be executed in the renderer process for that window.
// All of the Node.js APIs are available in this process.
const admin = require('firebase-admin');
var serviceAccount = require('./credentials.json');
admin.initializeApp({
credential: admin.credential.cert(serviceAccount),
databaseURL: "https://mytestapp.firebaseio.com"
});
var db = admin.firestore();
const settings = {
timestampsInSnapshots: true
};
db.settings(settings);
function LoadList() {
db.collection("Orders").get().then(function(Collection){
Collection.forEach(function(OrderDoc){
console.log(OrderDoc.id)
})
}).catch(function(err){
console.error(err);
});
}
document.querySelector('#ListSec').addEventListener('click', LoadOrderList)
Any ideas? I've been trying to solve this for hours, but can't seem to figure it out.
That error message indicates that gRPC was installed for Node, not for Electron. Electron has a different binary interface, so binary modules like gRPC need to be installed specifically for Electron. You can generally do this just by running npm rebuild --runtime=electron --target=2.0.0 (modified to match the version of Electron you want to use).
The original answer by #murgatroid99 was helpful at the time, and a postinstall command worked great up until electron v7, where the issue returned.
For anyone else who comes across this issue, I've found a better solution:
the electron-rebuild package
npm install electron-rebuild --save-dev
Run it using
npx electron-rebuild
Or, add it as a postinstall command
{
...
"scripts": {
"postinstall": "electron-rebuild"
},
...
}
Further information is in the official Electron Documentation

meteor keycloak third party

i want to test a keycloak request/response with a keycloak server in a docker file running on my localy machine.
The package Keycloak in atmospherejs doesnt work so i decided to include it to my meteor projekt as a third party library.
I put the library in a public/compatibility/keycloak/keycloak.js
The Autocomplete find it but if i use it then im getting a bug.
Exception while invoking method 'getTestToken' ReferenceError: Keycloak is not defined
But i do not understand it because it is correctly implemented as a thid party library in meteor. Can anybody help me to get this done?
Here I packaged the adapter library for meteor. Have not published it because I need to fork the original library and other stuff. Now you can call KeyCloak() on the client. Here's how I tested it in my router.js:
import { Keycloak } from 'meteor/mutdmour:keycloak'
Router.configure({
waitOn: [
function() {
console.log(Keycloak());
}
]
});
Here's what you can do to replicate what I did with other libraries:
create a package, now you can find it in your packages folder
meteor create --package mutdmour:keycloak
copied over the keycloak.js into packages/keycloak
changed the package.js file to reference the mainModule to run only on the client. This is why you are getting 'window is not defined'. Because it's running on the server. You could try putting that import in a if (Meteor.isClient()){...}
api.mainModule('keycloak.js', 'client');
added an export to package.js
api.export('Keycloak', 'client');
add the word export to the Keycloak definition in keycloak.js
export var Keycloak =
add the package
meteor add mutdmour:keycloak

Resources