Title
l

lastmjs

10/17/2017, 6:06 PM
event.environment is empty for me now with this function definition in graphcool.yml:
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

agartha

10/17/2017, 6:08 PM
Can you retry with the latest graphcool@next version (0.7.0)?
l

lastmjs

10/17/2017, 6:08 PM
a

agartha

10/17/2017, 6:11 PM
Hmmm... and
graphcool@alpha
(you can always go back of course...)
l

lastmjs

10/17/2017, 6:12 PM
a

agartha

10/17/2017, 6:17 PM
I just checked the sources, do you have a location for that bug?
l

lastmjs

10/17/2017, 6:17 PM
Like a line number and file?
a

agartha

10/17/2017, 6:17 PM
yes
l

lastmjs

10/17/2017, 6:18 PM
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

agartha

10/17/2017, 6:18 PM
hopefully, can you try
l

lastmjs

10/17/2017, 6:18 PM
Yes, let me try
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

agartha

10/17/2017, 6:22 PM
Seems to be a npm issue
Did you completely remove graphcool before installing another version?
l

lastmjs

10/17/2017, 6:22 PM
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

agartha

10/17/2017, 6:24 PM
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

lastmjs

10/17/2017, 6:25 PM
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

agartha

10/17/2017, 6:27 PM
That's it, it's not in the dependencies
l

lastmjs

10/17/2017, 6:27 PM
Hmmm
a

agartha

10/17/2017, 6:27 PM
Sorry, it is
l

lastmjs

10/17/2017, 6:27 PM
Oh
But judging from your install path, you don't install graphcool globally?
l

lastmjs

10/17/2017, 6:29 PM
That's right
I want to keep everything scoped to the project so a new developer can just npm install and start working
a

agartha

10/17/2017, 6:30 PM
Hmmm... I have never tried that (CLI commands don't work on Windows for local install)
l

lastmjs

10/17/2017, 6:30 PM
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

agartha

10/17/2017, 6:34 PM
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

lastmjs

10/17/2017, 6:40 PM
v8.4.0
a

agartha

10/17/2017, 6:42 PM
I'm out of ideas...
Is fs-extra in the node_modules folder?
l

lastmjs

10/17/2017, 6:43 PM
Yes
I just ran this in the node repl from my project's root directory:
const fs = require('fs-extra')
and
fs.pathExistsSync()
Then I get:
TypeError: fs.pathExistsSync is not a function
My version of fs-extra is:
0.30.0
a

agartha

10/17/2017, 6:46 PM
Aha
That version does not contain that method
l

lastmjs

10/17/2017, 6:46 PM
Yes!
So, graphcool has the dependency listed incorrectly? Maybe too liberal of a caret or something?
a

agartha

10/17/2017, 6:47 PM
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

lastmjs

10/17/2017, 6:48 PM
Even in that case, doesn't npm nest modules?
a

agartha

10/17/2017, 6:48 PM
Or you depend on another module that has a stricter version requirement?
l

lastmjs

10/17/2017, 6:48 PM
When there are conflicts?
a

agartha

10/17/2017, 6:48 PM
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

lastmjs

10/17/2017, 6:49 PM
It works with
npm install fs-extra
!
a

agartha

10/17/2017, 6:49 PM
exactly
But where does that earlier version come from?
l

lastmjs

10/17/2017, 6:49 PM
Let me look into it
electron-download
"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

agartha

10/17/2017, 6:52 PM
Aha
And where did that come from, graphql-playground?
l

lastmjs

10/17/2017, 6:52 PM
That's just from electron, which I installed separately:
"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

agartha

10/17/2017, 6:53 PM
Ah right, and installing graphcool didn't show a warning from npm?
l

lastmjs

10/17/2017, 6:54 PM
No, all I got after doing
npm install graphcool@next
was:
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

agartha

10/17/2017, 6:54 PM
I've got it
The dependency is ^0.4.1
l

lastmjs

10/17/2017, 6:55 PM
HO!!!
a

agartha

10/17/2017, 6:55 PM
0.30.0 satisfies that
l

lastmjs

10/17/2017, 6:55 PM
Okay, so just a typo
a

agartha

10/17/2017, 6:55 PM
?
l

lastmjs

10/17/2017, 6:56 PM
Should the dependency be ^4.0.1?
In graphcool?
a

agartha

10/17/2017, 6:56 PM
Wait
My mistake
^4.0.1
Sorry, long day...
l

lastmjs

10/17/2017, 6:56 PM
Haha, no problem
a

agartha

10/17/2017, 6:57 PM
So why does it accept your current 0.30.0 version?
l

lastmjs

10/17/2017, 6:57 PM
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

agartha

10/17/2017, 7:38 PM
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

lastmjs

10/17/2017, 7:51 PM
That sounds right to me
I tried to make it into an understandable story
Updated it a bit
l

lastmjs

10/17/2017, 8:43 PM
Great, looks good, thanks for the help
a

agartha

10/17/2017, 8:43 PM
You're welcome. I'm always intrigued by sh*t like this 😄
l

lastmjs

10/17/2017, 11:17 PM
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

agartha

10/17/2017, 11:17 PM
I think so...
l

lastmjs

10/17/2017, 11:18 PM
Hey, it works now, nevermind
a

agartha

10/17/2017, 11:19 PM
😄
The magical power of wishful thinking 😄
👍 1