nexus generate supabase url not found (env variable) - graphql

Prisma Nexus generate does not find environment variable
I have import 'dotenv/config' at the root of my Apollo Server set. So I can develop fine. However, when I try to run ts-node --transpile-only apollo/schema I get the following error.
This tells me that dotenv isn't running on generate. Is there a configuration for this somewhere?
/{user-path}/node_modules/#supabase/supabase-js/src/SupabaseClient.ts:62
if (!supabaseUrl) throw new Error('supabaseUrl is required.')
^
Error: supabaseUrl is required.
at new SupabaseClient (/{user-path}/node_modules/#supabase/supabase-js/src/SupabaseClient.ts:62:29)
at createClient (/{user-path}/node_modules/#supabase/supabase-js/src/index.ts:21:10)
at /{user-path}/apollo/src/supabase-client.ts:9:22
at Object.<anonymous> (/{user-path}/apollo/src/supabase-client.ts:10:3)
at Module._compile (node:internal/modules/cjs/loader:1101:14)
at Module.m._compile (/{user-path}/node_modules/ts-node/src/index.ts:1371:23)
at Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at Object.require.extensions.<computed> [as .ts] (/{user-path}/node_modules/ts-node/src/index.ts:1374:12)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
error Command failed with exit code 1.

I put import 'dotenv/config' at the root of the apollo server so running the server was fine. However, when I go to build the schema directly I don't get my env vars. So I also put the dotenv/config in my schema.ts. It's not a great solution since on server startup I config twice. But it works for now. Would appreciate to hear a better solution if anyone has one.

Related

Cypress parallel run with Browserstack

I'm trying to run Cypress BDD test suites with Browserstack but i kept getting this error
CYPRESS_RUN_FAILEDCypress failed to run. Hide stack trace [-]
The plugins file is missing or invalid.
Your pluginsFile is set to .\cypress\plugins\index.js, but either
the file is missing, it contains a syntax error, or threw an error
when required. The pluginsFile must be a .js, .ts, or .coffee
file.
Or you might have renamed the extension of your pluginsFile. If
that's the case, restart the test runner.
Please fix this, or set pluginsFile to false if a plugins file is
not necessary for your project.
Error: Cannot find module 'cypress-cucumber-preprocessor' Require
stack:
.\cypress\plugins\index.js
\cypress_package\4.12.1\app\packages\server\lib\plugins\child\run_plugins.js
\cypress_package\4.12.1\app\packages\server\lib\plugins\child\index.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:798:15)
at Module._load (internal/modules/cjs/loader.js:691:27)
at Module._load (electron/js2c/asar.js:717:26)
at Function.Module._load (electron/js2c/asar.js:717:26)
at Module.require (internal/modules/cjs/loader.js:853:19)
at require (internal/modules/cjs/helpers.js:74:18)
at Object. (.\cypress\plugins\index.js:2:18)
at Module._compile (internal/modules/cjs/loader.js:968:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:986:10)
at Module.load (internal/modules/cjs/loader.js:816:32)
at Module._load (internal/modules/cjs/loader.js:728:14)
at Module._load (electron/js2c/asar.js:717:26)
at Function.Module._load (electron/js2c/asar.js:717:26)
at Module.require (internal/modules/cjs/loader.js:853:19)
at require (internal/modules/cjs/helpers.js:74:18)
at module.exports (\cypress_package\4.12.1\app\packages\server\lib\plugins\child\run_plugins.js:208:15)
cypress run process exited with code 1 cypress run failed, exiting
with code: 1
After following the answer suggestion, it seems it cannot read my stepDef and Page class files;
enter image description here
From the stack trace, I see:
Cannot find module 'cypress-cucumber-preprocessor' Require stack
Looks like you're missing the dependency.
Cypress execution on BrowserStack requires you to explicitly mention the npm packages required by the test in the browserstack.json file.
Here's the documentation link: https://www.browserstack.com/docs/automate/cypress/npm-packages

Signed electron app does not start with robotjs on OSX (Unhandled Errpr: no suitable image found)

I have a signed and notarized App where I want to use robotjs to simulate key taps. I had no problems building robotjs locally but when I run it through the CI, where I sign and notarize the app, the app throws the following error upon starting:
electron/js2c/asar.js:140 Uncaught Error: dlopen(/var/folders/jh/c4kr0qwj0jz2g6qr9y62v3f80000gn/T/.com.electron.w3champions-launcher.JGzZcr, 1): no suitable image found. Did find:
/var/folders/jh/c4kr0qwj0jz2g6qr9y62v3f80000gn/T/.com.electron.w3champions-launcher.JGzZcr: code signature in (/var/folders/jh/c4kr0qwj0jz2g6qr9y62v3f80000gn/T/.com.electron.w3champions-launcher.JGzZcr) not valid for use in process using Library Validation: mapped file has no cdhash, completely unsigned? Code has to be at least ad-hoc signed.
/var/folders/jh/c4kr0qwj0jz2g6qr9y62v3f80000gn/T/.com.electron.w3champions-launcher.JGzZcr: stat() failed with errno=17
at process.func [as dlopen] (electron/js2c/asar.js:140)
at Object.Module._extensions..node (internal/modules/cjs/loader.js:1034)
at Object.func [as .node] (electron/js2c/asar.js:149)
at Module.load (internal/modules/cjs/loader.js:815)
at Module._load (internal/modules/cjs/loader.js:727)
at Function.Module._load (electron/js2c/asar.js:769)
at Module.require (internal/modules/cjs/loader.js:852)
at require (internal/modules/cjs/helpers.js:74)
at Object.<anonymous> (/Applications/w3champions-launcher.app/Contents/Resources/app.asar/node_modules/robotjs/index.js:1)
at Object.<anonymous> (/Applications/w3champions-launcher.app/Contents/Resources/app.asar/node_modules/robotjs/index.js:38)
I have the feeling that I do not sign the built robotjs stuff and therefore OSX is not happy when loading it. If I remove the notarize step, I get the same error. Those are my build commands:
"build": "npm run rebuild && vue-cli-service electron:build",
"rebuild": "npm rebuild --runtime=electron --target=9.1.2 --disturl=https://atom.io/download/atom-shell --abi=80",
I found something here: https://github.com/electron-userland/electron-builder/issues/4040#issuecomment-543252275 but I lack electron knowledge to make this happen. Also he uses react and a 2 package.json solution, which I do not have. Do I have to add a sign step for robotjs and if so, how do I do that? On Windows everything is working fine, no problem in signing and building.
this would be the repo:
https://github.com/w3champions/w3champions-launcher
Ok, i somehow stumbled over a post where something similar happened and fixed it. What I changed in my odyssey of google are the following things, maybe one of those might help someone:
In the vue.config.js I added
builderOptions.mac.entitlementsInherit = "build/entitlements.mac.inherit.plist". Earlier I only had builderOptions.mac.entitlements
I added those tow entitelments to my entitelments list:
<key>com.apple.security.cs.disable-library-validation</key>
<true/>
<key>com.apple.security.cs.disable-executable-page-protection</key>
<true/>
In the package.json i changed my build sightly to
"build": "npm run rebuild && vue-cli-service electron:build",
"rebuild": "npm rebuild --runtime=electron --target=9.1.2 -- disturl=https://atom.io/download/atom-shell --abi=80"
The change was mearly to make the abi the correct one. You can get the needed abi by electron --abi

Compile error when using the new mmlight with a preprocessing script

I've moved from the now deprecated jquery.mmenu (available at http://mmenu.frebsite.nl/) to mmlight (https://mmenujs.com/).
Same author, different version of the script, with the latter being more modern and short in size between the other things.
While using the new version in conjunction with a static site generator that has a pre-processing routine to compress Javascript I got an error that I was able to pin down to the line that contains the =>
document.addEventListener("DOMContentLoaded", () => {
Regrettably the error from the verbose is not helpful when it says:
SyntaxError: Unexpected token: punc ())
JS_Parse_Error.get ((execjs):3538:621)
(execjs):4060:48
(execjs):1:102
Object.<anonymous> ((execjs):1:120)
Module._compile (internal/modules/cjs/loader.js:738:30)
Object.Module._extensions..js (internal/modules/cjs/loader.js:749:10)
Module.load (internal/modules/cjs/loader.js:630:32)
tryModuleLoad (internal/modules/cjs/loader.js:570:12)
Function.Module._load (internal/modules/cjs/loader.js:562:3)
Function.Module.runMain (internal/modules/cjs/loader.js:801:12)
Does anybody have an idea on how to forward?
Is there any chance to rewrite the routine as a custom prototype or similar?
So apparently the issue is the new ES6 and Uglifier that doesn't support it in full yet as stated here https://github.com/lautis/uglifier
The workaround is to activate the compressor as per their recommendation.

Code coverage for Mocha in Windows 7

I am trying to do code coverage for mocha using istanbul which I have installed globally:
I do this as suggested here
E:\Do\learn_mocha>istanbul cover _mocha -- -R spec
C:\Users\Vamsi\AppData\Roaming\npm\_mocha.CMD:1
(function (exports, require, module, __filename, __dirname) { #IF EXIST "%~dp0
^
No coverage information was collected, exit without writing coverage information
SyntaxError: Unexpected token ILLEGAL
at Module._compile (module.js:439:25)
at Module._extensions..js (module.js:474:10)
at Object.Module._extensions..js (C:\Users\Vamsi\AppData\Roaming\npm\node_mo
dules\istanbul\lib\hook.js:102:13)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
at runFn (C:\Users\Vamsi\AppData\Roaming\npm\node_modules\istanbul\lib\comma
nd\common\run-with-cover.js:114:16)
at C:\Users\Vamsi\AppData\Roaming\npm\node_modules\istanbul\lib\command\comm
on\run-with-cover.js:232:17
at C:\Users\Vamsi\AppData\Roaming\npm\node_modules\istanbul\lib\util\file-ma
tcher.js:56:16
at C:\Users\Vamsi\AppData\Roaming\npm\node_modules\istanbul\lib\util\file-ma
tcher.js:35:9
This command also throws the same error as above:
E:\Do\learn_mocha>istanbul cover --hook-run-in-context _mocha -- -R spec
I was told by a github issue that I had to add a path to mocha from node_modules,so I did this:
E:\Do\learn_mocha>istanbul cover C:\Users\Vamsi\AppData\Roaming\npm\mocha -- -R
spec
C:\Users\Vamsi\AppData\Roaming\npm\mocha:2
basedir=`dirname "$0"`
^
No coverage information was collected, exit without writing coverage information
SyntaxError: Unexpected token ILLEGAL
at Module._compile (module.js:439:25)
at Module._extensions..js (module.js:474:10)
at Object.Module._extensions..js (C:\Users\Vamsi\AppData\Roaming\npm\node_mo
dules\istanbul\lib\hook.js:102:13)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
at runFn (C:\Users\Vamsi\AppData\Roaming\npm\node_modules\istanbul\lib\comma
nd\common\run-with-cover.js:114:16)
at C:\Users\Vamsi\AppData\Roaming\npm\node_modules\istanbul\lib\command\comm
on\run-with-cover.js:232:17
at C:\Users\Vamsi\AppData\Roaming\npm\node_modules\istanbul\lib\util\file-ma
tcher.js:56:16
at C:\Users\Vamsi\AppData\Roaming\npm\node_modules\istanbul\lib\util\file-ma
tcher.js:35:9
I am using Windows 7 as my OS
My test looks like this:
var assert = require("assert"); // core module
var C = require('../cash.js'); // our module
describe('Cash Register', function(){
describe('Module C', function(){
it('should have a getChange Method', function(){
assert.equal(typeof C, 'object');
assert.equal(typeof C.getChange, 'function');
})
it('getChange(210,300) should equal [50,20,20]',function(){
assert.deepEqual(C.getChange(210,300),[50,20,20]);
})
it('getChange(486,1000) should equal [500,10,2,2]',function(){
assert.deepEqual(C.getChange(486,1000),[500,10,2,2]);
})
it('getChange(1487,10000) should equal [5000,2000,1000,500,10,2,1]',function(){
assert.deepEqual(C.getChange(1487,10000),[5000,2000,1000,500,10,2,1]);
})
})
})
This worked for me:
I have both mocha and istanbul installed locally (no -g on the npm install).
I was running
*./node_modules/.bin/istanbul cover ./node_modules/.bin/_mocha*
and this came up with the error you were seeing above. I have changed this to look in the explicit local folder for mocha
*./node_modules/.bin/istanbul cover ./node_modules/mocha/bin/_mocha*
and now everything is working great.
Please note I'm running my setup under gitbash on windows 7
Try this one, it should work.
istanbul cover %APPDATA%/npm/node_modules/mocha/bin/_mocha -- -R spec
As per this comment in github, in windows the batch commands are not being resolved inside javascript. Hence causing the issue.
As per the suggestion, you can directly pass the javascript function for mocha to istanbul. Here is how you can do it
Type npm ls -g --depth=0
Copy the first line of the output.
it should be C:\Users\<YourUserName>\AppData\Roaming\npm
Type istanbul cover C:\Users\<YourUserName>\AppData\Roaming\npm\node_modules\mocha\bin\_mocha test\folder
So here instead of passing the _mocha(windows command), the javascript from your global mocha installation is being passed. This is exactly what, happening for the local installation of mocha in the previous answer.
Try this command:
istanbul cover C:\\Users\\username\\AppData\\Roaming\\npm\\node_modules\\mocha\\bin\\_mocha
^
Insert Your username here
Where username = Your username
Try:
istanbul cover %NODE_HOME%\node_modules\mocha\bin_mocha -- -R spec --recursive test

how do I tell cake where to look for coffee?

Setting up the express coffee app that twilson63 built. It seems that cake can't find coffee, but they both are ok with which. Is there something else I need to do here? Here's my steps:
jcollum#DEVELOPER01 ~/dev/express-coffee-master
$ which coffee
/c/Users/jcollum/AppData/Roaming/npm/node_modules/coffee-script/bin/coffee
OK coffee is there.
jcollum#DEVELOPER01 ~/dev/express-coffee-master
$ which cake
/c/Users/jcollum/AppData/Roaming/npm/node_modules/coffee-script/bin/cake
And so is cake.
jcollum#DEVELOPER01 ~/dev/express-coffee-master
$ cake
Cakefile defines the following tasks:
cake docs # Generate annotated source code with Docco
cake build
cake spec # Run Mocha tests
cake test # Run Mocha tests
cake dev # start dev env
cake debug # start debug env
cake scaffold # scaffold model/controller/test
-n, --name name of model to `scaffold`
Cake found a cakefile locally.
jcollum#DEVELOPER01 ~/dev/express-coffee-master
$ cake dev
c:\Users\jcollum\dev\express-coffee-master\node_modules\which\which.js:83
throw new Error("not found: "+cmd)
^
Error: not found: coffee
at Function.whichSync [as sync] (c:\Users\jcollum\dev\express-coffee-master\node_modules\which\which.js:83:9)
at Object.options [as action] (c:\Users\jcollum\dev\express-coffee-master\Cakefile:121:17)
at helpers.extend.invoke (c:\Users\jcollum\AppData\Roaming\npm\node_modules\coffee-script\lib\coffee-script\cake.js:44:26)
at Object.exports.run (c:\Users\jcollum\AppData\Roaming\npm\node_modules\coffee-script\lib\coffee-script\cake.js:69:21)
at Object.<anonymous> (c:\Users\jcollum\AppData\Roaming\npm\node_modules\coffee-script\bin\cake:7:38)
at Module._compile (module.js:449:26)
at Object.Module._extensions..js (module.js:467:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.runMain (module.js:492:10)
Bzzzzttt! Nope. I suspect this is an issue with Windows 7 and node not playing all that nicely together.
Seems the answer was to make sure I had a NODE_PATH in my env:
export NODE_PATH=/c/Users/jcollum/AppData/Roaming/npm:/c/Users/jcollum/AppData/Roaming/npm/node_modules
Either that, or adding the node_modules to my PATH in .bash_profile.
Got the idea here: https://github.com/replit/jsrepl/issues/56

Resources