event.environment is empty for me now with this fu...
# prisma-whats-new
l
event.environment is empty for me now with this function definition in graphcool.yml:
Copy code
assignment-lti-launch:
        handler:
            code:
                src: ./functions/assignment-lti-launch/assignment-lti-launch.js
                environment:
                    PRENDUS_LTI_SECRET: ${env:PRENDUS_LTI_SECRET}
        type: resolver
        schema: ./functions/assignment-lti-launch/assignment-lti-launch.graphql
1
I'm on graphcool@0.7.0-beta.12
a
Can you retry with the latest graphcool@next version (0.7.0)?
l
a
Hmmm... and
graphcool@alpha
(you can always go back of course...)
l
a
I just checked the sources, do you have a location for that bug?
l
Like a line number and file?
a
yes
l
I haven't dug through the source code, and the error doesn't give any information on where its coming from
Will enabling debugging give me more info?
a
hopefully, can you try
l
Yes, let me try
Copy code
TypeError: fs.pathExistsSync is not a function
    at Bundler.<anonymous> (/home/lastmj/development/prendus/prendus-app/node_modules/graphcool-cli-core/src/commands/deploy/Bundler/Bundler.ts:65:13)
    at step (/home/lastmj/development/prendus/prendus-app/node_modules/graphcool-cli-core/dist/commands/deploy/Bundler/Bundler.js:40:23)
    at Object.next (/home/lastmj/development/prendus/prendus-app/node_modules/graphcool-cli-core/dist/commands/deploy/Bundler/Bundler.js:21:53)
    at /home/lastmj/development/prendus/prendus-app/node_modules/graphcool-cli-core/dist/commands/deploy/Bundler/Bundler.js:15:71
    at Promise (<anonymous>)
    at __awaiter (/home/lastmj/development/prendus/prendus-app/node_modules/graphcool-cli-core/dist/commands/deploy/Bundler/Bundler.js:11:12)
    at Bundler.bundle (/home/lastmj/development/prendus/prendus-app/node_modules/graphcool-cli-core/dist/commands/deploy/Bundler/Bundler.js:82:16)
    at Deploy.<anonymous> (/home/lastmj/development/prendus/prendus-app/node_modules/graphcool-cli-core/src/commands/deploy/index.ts:232:43)
    at step (/home/lastmj/development/prendus/prendus-app/node_modules/graphcool-cli-core/dist/commands/deploy/index.js:42:23)
    at Object.next (/home/lastmj/development/prendus/prendus-app/node_modules/graphcool-cli-core/dist/commands/deploy/index.js:23:53)
    at /home/lastmj/development/prendus/prendus-app/node_modules/graphcool-cli-core/dist/commands/deploy/index.js:17:71
    at Promise (<anonymous>)
    at __awaiter (/home/lastmj/development/prendus/prendus-app/node_modules/graphcool-cli-core/dist/commands/deploy/index.js:13:12)
    at Deploy.deploy (/home/lastmj/development/prendus/prendus-app/node_modules/graphcool-cli-core/dist/commands/deploy/index.js:224:16)
    at Deploy.<anonymous> (/home/lastmj/development/prendus/prendus-app/node_modules/graphcool-cli-core/src/commands/deploy/index.ts:164:16)
    at step (/home/lastmj/development/prendus/prendus-app/node_modules/graphcool-cli-core/dist/commands/deploy/index.js:42:23)
a
Seems to be a npm issue
Did you completely remove graphcool before installing another version?
l
No
I'm using npm 5+
And Node 8+
So it shouldn't be an issue, but let me try that
Didn't work
a
Well, can you check
/home/lastmj/development/prendus/prendus-app/node_modules/graphcool-cli-core/src/commands/deploy/Bundler/Bundler.ts
And see if it imports
* as 'fs' from 'fs-extra'
?
l
That file doesn't exist on my system
You know, this might be a transitive dependency issue
Does the graphcool project have a package-lock.json?
It does
It doesn't look like it's being used
a
That's it, it's not in the dependencies
l
Hmmm
a
Sorry, it is
l
Oh
But judging from your install path, you don't install graphcool globally?
l
That's right
I want to keep everything scoped to the project so a new developer can just npm install and start working
a
Hmmm... I have never tried that (CLI commands don't work on Windows for local install)
l
And I just throw all commands into npm scripts
Is the graphcool npm install doing anything out of the ordinary with its installation that might help me figure this out?
a
Not that I'm aware of
The thing is, that command is used throughout the CLI everywhere, so it's very strange you run into it with bundling
Which node version are you running?
l
v8.4.0
a
I'm out of ideas...
Is fs-extra in the node_modules folder?
l
Yes
I just ran this in the node repl from my project's root directory:
Copy code
const fs = require('fs-extra')
and
Copy code
fs.pathExistsSync()
Then I get:
Copy code
TypeError: fs.pathExistsSync is not a function
My version of fs-extra is:
0.30.0
a
Aha
That version does not contain that method
l
Yes!
So, graphcool has the dependency listed incorrectly? Maybe too liberal of a caret or something?
a
Was added after 3.0.0
No, the dependencies are specified correctly as ^4.0.1
Maybe your package.json contains a dependency as well for it?
l
Even in that case, doesn't npm nest modules?
a
Or you depend on another module that has a stricter version requirement?
l
When there are conflicts?
a
No since npm 5 not anymore (I think)
Well, in case of conflicts I'm not sure
But normally, all modules are flattened now
Can you manually install fs-extra@4.0.1
l
It works with
npm install fs-extra
!
a
exactly
But where does that earlier version come from?
l
Let me look into it
electron-download
Copy code
"electron-download": {
      "version": "3.3.0",
      "resolved": "<https://registry.npmjs.org/electron-download/-/electron-download-3.3.0.tgz>",
      "integrity": "sha1-LP1U1pZsAZxNSa1l++Zcyc3vaMg=",
      "dev": true,
      "requires": {
        "debug": "2.6.8",
        "fs-extra": "0.30.0",
        "home-path": "1.0.5",
        "minimist": "1.2.0",
        "nugget": "2.0.1",
        "path-exists": "2.1.0",
        "rc": "1.2.1",
        "semver": "5.4.1",
        "sumchecker": "1.3.1"
      },
      "dependencies": {
        "fs-extra": {
          "version": "0.30.0",
          "resolved": "<https://registry.npmjs.org/fs-extra/-/fs-extra-0.30.0.tgz>",
          "integrity": "sha1-8jP/zAjU2n1DLapEl3aYnbHfk/A=",
          "dev": true,
          "requires": {
            "graceful-fs": "4.1.11",
            "jsonfile": "2.4.0",
            "klaw": "1.3.1",
            "path-is-absolute": "1.0.1",
            "rimraf": "2.6.1"
          }
        },
        "jsonfile": {
          "version": "2.4.0",
          "resolved": "<https://registry.npmjs.org/jsonfile/-/jsonfile-2.4.0.tgz>",
          "integrity": "sha1-NzaitCi4e72gzIO1P6PWM6NcKug=",
          "dev": true,
          "requires": {
            "graceful-fs": "4.1.11"
          }
        }
      }
    }
a
Aha
And where did that come from, graphql-playground?
l
That's just from electron, which I installed separately:
Copy code
"electron": {
      "version": "1.6.11",
      "resolved": "<https://registry.npmjs.org/electron/-/electron-1.6.11.tgz>",
      "integrity": "sha1-vnnA69zv7bW/KBF0CYAPpTus7/o=",
      "dev": true,
      "requires": {
        "@types/node": "7.0.39",
        "electron-download": "3.3.0",
        "extract-zip": "1.6.5"
      }
    }
a
Ah right, and installing graphcool didn't show a warning from npm?
l
No, all I got after doing
npm install graphcool@next
was:
Copy code
npm WARN deprecated xlsjs@0.7.6: xlsjs has been merged into xlsx module
npm WARN ajv-keywords@2.1.0 requires a peer of ajv@>=5.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN prendus-app@0.4.0 No license field.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.1.2 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.1.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

+ graphcool@0.7.0
a
I've got it
The dependency is ^0.4.1
l
HO!!!
a
0.30.0 satisfies that
l
Okay, so just a typo
a
?
l
Should the dependency be ^4.0.1?
In graphcool?
a
Wait
My mistake
^4.0.1
Sorry, long day...
l
Haha, no problem
a
So why does it accept your current 0.30.0 version?
l
I'm looking into conflict resolution in npm 5
Let me redo these installs and check some things out
Great, now I can't reproduce it
I'm completely deleting my node_modules folder, uninstalling fs-extra, and doing another install
It seems to work every time now
As far as I understand, npm 5 still nests dependencies and isn't planning on flat installs by default
That comes from some twitter conversation I read and some observations
I can see evidence of this now, as the electron-download directory in node_modules has its own node_modules folder, with fs-extra 0.30.0
And then in the main node_modules directory I have fs-extra version 4.0.2
I don't know why it didn't get sorted out before, but with a fresh install after deleted node_modules, it seems to sort itself out every time
Let me try one more thing
Alright, I reproduced it and I think I know the issue
So, it's as I thought. To deal with conflicts, npm nests
So, because fs-extra 0.30.0 was already installed at the top level, when I then installed graphcool, fs-extra was nested within node_modules/graphcool
So, the require in graphcool is retrieving the fs-extra 0.30.0 that was already installed at the top node_modules level, and is not grabbing the nested version
I'm also trying to find real documentation on this
a
Check
So graphcool first, electron later, fs-extra 0.30.0 becomes nested under electron, and works
or is electron also using the newer version in that case?
electron first, graphcool later, nested version is installed under graphcool, but it isn't used
Found it
It has to do with the bundling
graphcool-cli has fs-extra in the package.json
now, graphcool-cli-core is the package that actually depends on it
But, because it is already in the graphcool-cli package, it is not in the package.json of graphcool-cli-core
Now, npm flattens modules
And will install the conflicting version under graphcool-cli/node_modules, NOT graphcool-cli-core/node_modules
So when graphcool-cli-core tries to resolve fs-extra
It does not find it in its own node_modules folder
And starts looking up, finding your electron installed 0.30.0 version
l
That sounds right to me
I tried to make it into an understandable story
Updated it a bit
l
Great, looks good, thanks for the help
a
You're welcome. I'm always intrigued by sh*t like this 😄
l
So now I'm back to my original problem, I'm trying to access my environment variables but they don't seem to be there
I used to be able to access environment variables through
process.env
, is that still supposed to work?
a
I think so...
l
Hey, it works now, nevermind
a
😄
The magical power of wishful thinking 😄
👍 1