Closed emroot closed 4 years ago
Could you set LOG_LEVEL=trace
, re-run build, and share the output? Looks like an issue with project layout calculation.
I'm experiencing the same issue. dev
works fine, but build
fails.
Full output:
✘ ~/Coding/experiments/nexus-graphql master ● yarn build
yarn run v1.21.1
$ nexus build
3123 ● nexus:build Running typegen & extracting types from addToContext calls
341 ✕ app uncaughtException
| error Error: Cannot find module './graphql/hackernews'
| Require stack:
| - /Users/name/Coding/experiments/nexus-graphql/node_modules/.build/index.js
| at Function.Module._resolveFilename (internal/modules/cjs/loader.js:966:17)
| at Function.Module._load (internal/modules/cjs/loader.js:859:27)
| at Module.require (internal/modules/cjs/loader.js:1028:19)
| at require (internal/modules/cjs/helpers.js:72:18)
| at Object.<anonymous> (/Users/name/Coding/experiments/nexus-graphql/node_modules/.build/index.js:23:1)
| at Module._compile (internal/modules/cjs/loader.js:1139:30)
| at Object.Module._extensions..js (internal/modules/cjs/loader.js:1159:10)
| at Module.load (internal/modules/cjs/loader.js:988:32)
| at Function.Module._load (internal/modules/cjs/loader.js:896:14)
| at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12) {
| code: 'MODULE_NOT_FOUND',
| requireStack: [
| '/Users/name/Coding/experiments/nexus-graphql/node_modules/.build/index.js'
| ]
| }
551 ✕ nexus:build failed to generate artifacts
| error Error:
| Nexus artifact generation failed with exit code "1". The following stderr was captured:
|
| null
|
| at Object.generateArtifacts (/Users/name/Coding/experiments/nexus-graphql/node_modules/nexus/src/lib/build/artifact-generation.ts:30:11)
| at Object.buildNexusApp (/Users/name/Coding/experiments/nexus-graphql/node_modules/nexus/src/lib/build/build.ts:86:5)
| at Build.parse (/Users/name/Coding/experiments/nexus-graphql/node_modules/nexus/src/cli/commands/build.ts:32:5)
| at main (/Users/name/Coding/experiments/nexus-graphql/node_modules/nexus/src/cli/main.ts:86:18)
error Command failed with exit code 1.
Taking a look at /Users/name/Coding/experiments/nexus-graphql/node_modules/.build/index.js
, I suspect that the relative path is the issue:
require('../../package.json');
// Import the user's schema modules
require("./graphql/hackernews");
require("./graphql");
// Import the user's app module
require("./app");
Note that package.json
includes the expected ../../
, but the other require's don't.
Seeing
LOG_LEVEL=trace yarn build
Would be helpful
Of course!
✘ ~/Coding/sites/hackernews master ● LOG_LEVEL=trace yarn build
yarn run v1.21.1
$ nexus build
734 — nexus:layout starting scan...
1 — nexus:layout looking for app module
279 — nexus:layout done looking for app module
251 — nexus:layout ...completed scan
| result {
| app: { exists: true, path: '/Users/name/Coding/sites/hackernews/api/app.ts' },
| projectRoot: '/Users/name/Coding/sites/hackernews',
| sourceRoot: '/Users/name/Coding/sites/hackernews/api',
| schemaModules: [ '/Users/name/Coding/sites/hackernews/api/graphql/hackernews.ts' ],
| sourceRootRelative: 'api',
| project: { name: 'hackernews', isAnonymous: false },
| packageManagerType: 'npm',
| packageJson: {
| content: {
| name: 'hackernews',
| license: 'UNLICENSED',
| dependencies: { axios: '^0.19.2', nexus: '0.20.0-next.42', 'nexus-plugin-prisma': '^0.7.0' },
| scripts: { format: "npx prettier --write './**/*.{ts,md}'", dev: 'nexus dev', build: 'nexus build', start: 'node node_modules/.build' },
| prettier: { semi: false, singleQuote: true, trailingComma: 'all' },
| devDependencies: { prettier: '^2.0.4' }
| },
| path: '/Users/name/Coding/sites/hackernews/package.json',
| dir: '/Users/name/Coding/sites/hackernews'
| }
| }
4 — nexus:compiler config file search result -- fileName: 'tsconfig.json' configPath: '/Users/name/Coding/sites/hackernews/tsconfig.json' opts: { required: false }
10 — nexus:start-module create start module
1 — nexus:start-module created
| content '// GENERATED NEXUS START MODULE\n' +
| '\n' +
| '\n' +
| '\n' +
| "process.env.NEXUS_SHOULD_GENERATE_ARTIFACTS = 'true'process.env.NEXUS_DISABLE_SERVER = 'true'\n" +
| '\n' +
| '\n' +
| "process.env.NEXUS_STAGE = 'dev'\n" +
| '\n' +
| '\n' +
| '// Run framework initialization side-effects\n' +
| '// Also, import the app for later use\n' +
| 'const app = require("/Users/name/Coding/sites/hackernews/node_modules/nexus/dist/index.js").default\n' +
| '\n' +
| '\n' +
| '// Last resort error handling\n' +
| "process.once('uncaughtException', error => {\n" +
| " app.log.fatal('uncaughtException', { error: error })\n" +
| ' process.exit(1)\n' +
| '})\n' +
| '\n' +
| "process.once('unhandledRejection', error => {\n" +
| " app.log.fatal('unhandledRejection', { error: error })\n" +
| ' process.exit(1)\n' +
| '})\n' +
| '\n' +
| '\n' +
| '// package.json is needed for plugin auto-import system.\n' +
| '// On the Zeit Now platform, builds and dev copy source into\n' +
| '// new directory. Copying follows paths found in source. Give one here\n' +
| '// to package.json to make sure Zeit Now brings it along.\n' +
| "require('/Users/name/Coding/sites/hackernews/package.json')\n" +
| '\n' +
| '\n' +
| "// Import the user's schema modules\n" +
| ' \n' +
| "import '/Users/name/Coding/sites/hackernews/api/graphql/hackernews'\n" +
| '\n' +
| '\n' +
| "// Import the user's app module\n" +
| 'require("/Users/name/Coding/sites/hackernews/api/app")\n' +
| '\n' +
| '\n' +
| '// Boot the server if the user did not already.\n' +
| 'if (app.__state.isWasServerStartCalled === false) {\n' +
| ' app.server.start()\n' +
| "}process.env.NEXUS_DISABLE_SERVER = 'false'"
106 — nexus:plugin loaded plugin entrypoints
| validPlugins [
| {
| packageJsonPath: '/Users/name/Coding/sites/hackernews/node_modules/nexus-plugin-prisma/package.json',
| runtime: { module: '/Users/name/Coding/sites/hackernews/node_modules/nexus-plugin-prisma/dist/runtime.js', export: 'plugin' },
| worktime: { module: '/Users/name/Coding/sites/hackernews/node_modules/nexus-plugin-prisma/dist/worktime.js', export: 'plugin' },
| testtime: { module: '/Users/name/Coding/sites/hackernews/node_modules/nexus-plugin-prisma/dist/testtime.js', export: 'plugin' }
| }
| ]
551 — nexus:plugin loading worktime plugin -- name: 'nexus-plugin-prisma'
1 — nexus:plugin:nexus-plugin-prisma start
0 ● nexus:plugin:nexus-plugin-prisma Running Prisma generators ...
1 — nexus:plugin:nexus-plugin-prisma .env file found. Looked at: /Users/name/Coding/sites/hackernews/prisma/.env
0 — nexus:plugin:nexus-plugin-prisma loading generators...
345 — nexus:plugin:nexus-plugin-prisma generators loaded.
0 — nexus:plugin:nexus-plugin-prisma generating -- name: 'Prisma Client' instanceName: 'prisma_client' output: '/Users/name/Coding/sites/hackernews/node_modules/@prisma/client'
79 — nexus:plugin:nexus-plugin-prisma done generating -- name: 'Prisma Client' instanceName: 'prisma_client' output: '/Users/name/Coding/sites/hackernews/node_modules/@prisma/client'
0 — nexus:compiler config file search result -- fileName: 'tsconfig.json' configPath: '/Users/name/Coding/sites/hackernews/tsconfig.json' opts: { required: true }
6 — nexus:compiler Create TypeScript program
1294 — nexus:build Compiling a development build for typegen
1384 — nexus:start-module create start module
1 — nexus:start-module created
| content '// GENERATED NEXUS START MODULE\n' +
| '\n' +
| '\n' +
| '\n' +
| "process.env.NEXUS_SHOULD_GENERATE_ARTIFACTS = 'true'\n" +
| '\n' +
| '\n' +
| '// Run framework initialization side-effects\n' +
| '// Also, import the app for later use\n' +
| 'const app = require("nexus").default\n' +
| '\n' +
| '\n' +
| '// Last resort error handling\n' +
| "process.once('uncaughtException', error => {\n" +
| " app.log.fatal('uncaughtException', { error: error })\n" +
| ' process.exit(1)\n' +
| '})\n' +
| '\n' +
| "process.once('unhandledRejection', error => {\n" +
| " app.log.fatal('unhandledRejection', { error: error })\n" +
| ' process.exit(1)\n' +
| '})\n' +
| '\n' +
| '\n' +
| '// package.json is needed for plugin auto-import system.\n' +
| '// On the Zeit Now platform, builds and dev copy source into\n' +
| '// new directory. Copying follows paths found in source. Give one here\n' +
| '// to package.json to make sure Zeit Now brings it along.\n' +
| "require('../../package.json')\n" +
| '\n' +
| '\n' +
| "// Import the user's schema modules\n" +
| ' \n' +
| "import './graphql/hackernews'\n" +
| '\n' +
| '\n' +
| "// Import the user's app module\n" +
| 'require("./app")\n' +
| '\n' +
| '\n' +
| '// Statically import runtime plugins for tree-shaking\n' +
| "import { plugin as plugin_0 } from 'nexus-plugin-prisma/dist/runtime'\n" +
| '\n' +
| '\n' +
| '// Boot the server if the user did not already.\n' +
| 'if (app.__state.isWasServerStartCalled === false) {\n' +
| ' app.server.start()\n' +
| '}'
1 — nexus:start-module Transpiling start module
10 — nexus:build Writing start module to disk
3 ● nexus:build Running typegen & extracting types from addToContext calls
0 — nexus:add-to-context-extractor got app source files
| count 3
| files [
| '/Users/name/Coding/sites/hackernews/api/app.ts',
| '/Users/name/Coding/sites/hackernews/services/hackernews.ts',
| '/Users/name/Coding/sites/hackernews/api/graphql/hackernews.ts'
| ]
2 — nexus:add-to-context-extractor found call -- text: 'addToContext'
8 — nexus:add-to-context-extractor found call arg
| text '(req) => {\n' +
| ' return {\n' +
| ' hackernewsSession: {\n' +
| " ssId: req.headers['hackernews-ssid'] as string,\n" +
| " ssPid: req.headers['hackernews-sspid'] as string,\n" +
| ' },\n' +
| ' }\n' +
| '}'
1 — nexus:add-to-context-extractor processing prop -- name: 'hackernewsSession'
86 — nexus:add-to-context-extractor found prop type alias symbol? -- found: false
1 — nexus:add-to-context-extractor found prop type symbol? -- found: true
0 — nexus:add-to-context-extractor finished compiler extension processing -- contextTypeContributions: { typeImports: [], types: [ '{ hackernewsSession: { ssId: string; ssPid: string; }; }' ] }
1 — nexus:typegen start
486 ✕ app uncaughtException
| error Error: Cannot find module './graphql/hackernews'
| Require stack:
| - /Users/name/Coding/sites/hackernews/node_modules/.build/index.js
| at Function.Module._resolveFilename (internal/modules/cjs/loader.js:966:17)
| at Function.Module._load (internal/modules/cjs/loader.js:859:27)
| at Module.require (internal/modules/cjs/loader.js:1028:19)
| at require (internal/modules/cjs/helpers.js:72:18)
| at Object.<anonymous> (/Users/name/Coding/sites/hackernews/node_modules/.build/index.js:23:1)
| at Module._compile (internal/modules/cjs/loader.js:1139:30)
| at Object.Module._extensions..js (internal/modules/cjs/loader.js:1159:10)
| at Module.load (internal/modules/cjs/loader.js:988:32)
| at Function.Module._load (internal/modules/cjs/loader.js:896:14)
| at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12) {
| code: 'MODULE_NOT_FOUND',
| requireStack: [ '/Users/name/Coding/sites/hackernews/node_modules/.build/index.js' ]
| }
690 ✕ nexus:build failed to generate artifacts
| error Error:
| Nexus artifact generation failed with exit code "1". The following stderr was captured:
|
| null
|
| at Object.generateArtifacts (/Users/name/Coding/sites/hackernews/node_modules/nexus/src/lib/build/artifact-generation.ts:30:11)
| at Object.buildNexusApp (/Users/name/Coding/sites/hackernews/node_modules/nexus/src/lib/build/build.ts:86:5)
| at Build.parse (/Users/name/Coding/sites/hackernews/node_modules/nexus/src/cli/commands/build.ts:32:5)
| at main (/Users/name/Coding/sites/hackernews/node_modules/nexus/src/cli/main.ts:86:18)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Seems I found the issue: I had a "services" folder that resided next to (but not inside) "api". It was not totally apparent to me, that ./api
was the source directory.
Maybe the error message could be adjusted? I would probably also expect api
to be called src
or something similar, but I'm sure there's a reason why it's called api
:)
Thanks @DerJacques!
Nexus special cases app.ts
. The folder it is in is considered the source root. This is not mentioned in the docs, I will do so now.
Maybe the heuristic here should change. Any suggestions?
Could you share how your source tree is laid out. Seeing your tsconfig file would help.
Nexus source root and tsconfig rootDir
should always agree, when they don't maybe Nexus should either clearly error or match what user has set in their tsconfig.
~I was able to repro ish by not setting sourceRoot
in a tsconfig and doing:~
I was able to repro ish by:
api/
app.ts <-- imports foo.ts
services/
foo.ts
This led to a build failure during typegen.
Nexus considered the source root to be api/
.
TS considered the source root to be .
.
This led to a situation where the build output looked like this:
node_modules/
api/
services/
index.js <-- start module
Start module "thinks" the layout is like this:
graphql.js
app.js
index.js <-- start module
I was able to trigger failure in two ways:
Set rootDir
in tsconfig
"rootDir": "."
Build will work but node start
will fail:
node node_modules/.build
252 ✕ app uncaughtException
| error Error: Cannot find module './graphql'
| Require stack:
| - /Users/jasonkuhrt/hello/node_modules/.build/index.js
| at Function.Module._resolveFilename (internal/modules/cjs/loader.js:793:17)
| at Function.Module._load (internal/modules/cjs/loader.js:686:27)
| at Module.require (internal/modules/cjs/loader.js:848:19)
| at require (internal/modules/cjs/helpers.js:74:18)
| at Object.<anonymous> (/Users/jasonkuhrt/hello/node_modules/.build/index.js:23:1)
| at Module._compile (internal/modules/cjs/loader.js:955:30)
| at Object.Module._extensions..js (internal/modules/cjs/loader.js:991:10)
| at Module.load (internal/modules/cjs/loader.js:811:32)
| at Function.Module._load (internal/modules/cjs/loader.js:723:14)
| at Function.Module.runMain (internal/modules/cjs/loader.js:1043:10) {
| code: 'MODULE_NOT_FOUND',
| requireStack: [ '/Users/jasonkuhrt/hello/node_modules/.build/index.js' ]
| }
api/
app.ts <-- imports foo.ts
services/
foo.ts
Build will fail on typegen.
In both cases the root issue is a difference between:
1. Nexus considered the source root to be `api/`.
2. TS considered the source root to be `.`.
This led to a situation where the build output looked like this:
node_modules/
api/
services/
index.js <-- start module
Start module "thinks" the layout is like this:
graphql.js
app.js
index.js <-- start module
In terms of solving this I am struggling on this part right now https://github.com/graphql-nexus/nexus/blob/c4154fe295ca8fd1326da14dd6789a5033a67c06/src/lib/tsc.ts#L98. Despite setting the sourceRoot explicitly TS compilation goes by the layout of modules it finds rather than this value. I don't know how to control that yet.
A bit of investigation just now shows that to make TS error on a rootDir
that doesn't contain all inputs outDir
must also be set:
I confirmed that this behaviour holds for our nexus build
too. This means that our programatic manipulations are not actually having the effect we think they are.
I found one way to detect invalid layouts I think.
Once a program is created we can list all the source files in the project. This reveals every TS module that is considered part of the program. Then we can look for modules that fall outside the source root as Nexus sees it. Notes:
we have to filter modules from node_modules out of there. For example:
'/Users/jasonkuhrt/projects/graphql-nexus/nexus/node_modules/type-fest/source/require-at-least-one.d.ts'
linked packages will show up as not coming from node_modules. For example:
'/Users/jasonkuhrt/projects/graphql-nexus/nexus/plugin.d.ts',
This will happen for example during development.
I do not see a way to filter these out reliably, or painstaking hard to maintain and get right code. E.g. Filter by cross referencing state of node_modules folder. Unrealistic solution.
I can only see that we're forced to filter by what falls within the Nexus project dir.
I am not sure this is ok, but I see no issue so far.
Once we've filtered down the last to anything within the Nexus project root, we would look for any modules that fall outside the Nexus source root. If this is the case, it should reliably imply that one of the two cases I outlined above have occurred.
We're basically trying to re-create the file is not in 'rootDir'
check from TS. I am not convinced I have found the best way. Maybe we can lean on TS compiler api to make this check.
Currently this logic lives at the tsc level, but really we want it sooner, at the layout level. We should detect programs that we know won't compile as soon as possible. Right now things work in dev but then blow up in/after build.
19 — nexus:layout done looking for app module
20 — nexus:layout ...completed scan
| result { app:
| { exists: true,
| path: '/Users/emroot/code/catalist/packages/backend/src/app.ts' },
| projectRoot: '/Users/emroot/code/catalist/packages/backend',
| sourceRoot: '/Users/emroot/code/catalist/packages/backend/src',
| schemaModules:
| [ '/Users/emroot/code/catalist/packages/backend/src/graphql/collection.ts',
| '/Users/emroot/code/catalist/packages/backend/src/graphql/inputs.ts',
| '/Users/emroot/code/catalist/packages/backend/src/graphql/list.ts',
| '/Users/emroot/code/catalist/packages/backend/src/graphql/listItem.ts',
| '/Users/emroot/code/catalist/packages/backend/src/graphql/mutation.ts',
| '/Users/emroot/code/catalist/packages/backend/src/graphql/providerItem.ts',
| '/Users/emroot/code/catalist/packages/backend/src/graphql/providerItemAttribute.ts',
| '/Users/emroot/code/catalist/packages/backend/src/graphql/providerSearchResult.ts',
| '/Users/emroot/code/catalist/packages/backend/src/graphql/query.ts',
| '/Users/emroot/code/catalist/packages/backend/src/graphql/scalars.ts',
| '/Users/emroot/code/catalist/packages/backend/src/graphql/types.ts',
| '/Users/emroot/code/catalist/packages/backend/src/graphql/user.ts' ],
| sourceRootRelative: 'src',
| project: { name: '@catalist/backend', isAnonymous: false },
| packageManagerType: 'npm',
| packageJson:
| { content:
| { name: '@catalist/backend',
| version: '1.0.0',
| main: 'src/index.ts',
| author: 'Emre Ozdemir<emroot@gmail.com>',
| license: 'MIT',
| private: true,
| dependencies:
| { '@prisma/client': '^2.0.0-beta.2',
| '@types/amazon-product-api': '^0.0.33',
| '@types/bcryptjs': '^2.4.2',
| '@types/cookie-parser': '^1.4.2',
| '@types/cors': '^2.8.6',
| '@types/ioredis': '^4.14.9',
| '@types/jsonwebtoken': '^8.3.8',
| '@types/luxon': '^1.21.0',
| '@types/passport': '^1.0.2',
| '@types/passport-google-oauth20': '^2.0.3',
| 'amazon-product-api': '^0.4.4',
| axios: '^0.19.2',
| bcryptjs: '^2.4.3',
| 'cookie-parser': '^1.4.4',
| cors: '^2.8.5',
| dayjs: '^1.8.23',
| express: '^4.17.1',
| ioredis: '^4.16.0',
| jsonwebtoken: '^8.5.1',
| 'justwatch-api': '^1.0.7',
| luxon: '^1.22.0',
| nexus: '^0.20.0-next.41',
| 'nexus-plugin-prisma': '^0.7.0',
| passport: '^0.4.1',
| 'passport-apple': '^1.0.0',
| 'passport-google-oauth': '^2.0.0',
| 'passport-google-oauth20': '^2.0.0',
| querystring: '^0.2.0',
| simplur: '^1.1.0',
| 'ts-node': '^8.6.2',
| typescript: '^3.8.3' },
| scripts:
| { build: 'npm -s run clean && tsc',
| clean: 'rm -rf dist',
| 'start:dev': 'nexus dev',
| 'start:production': 'node dist/server',
| start:
| 'if test "$NODE_ENV" = "production" ; then yarn run start:production; else yarn run start:dev; fi' },
| devDependencies:
| { '@prisma/cli': '^2.0.0-beta.2',
| '@typescript-eslint/eslint-plugin': '^2.27.0',
| eslint: '^6.8.0',
| 'eslint-config-airbnb': '^18.1.0',
| 'eslint-plugin-import': '^2.20.2',
| 'eslint-plugin-jsx-a11y': '^6.2.3',
| 'eslint-plugin-react': '^7.19.0',
| 'eslint-plugin-react-hooks': '^3.0.0',
| 'graphql-cli': '^3.0.14',
| nodemon: '^2.0.2',
| 'ts-node-dev': '^1.0.0-pre.44' } },
| path: '/Users/emroot/code/catalist/packages/backend/package.json',
| dir: '/Users/emroot/code/catalist/packages/backend' } }
7 — nexus:compiler config file search result
| fileName 'tsconfig.json'
| configPath '/Users/emroot/code/catalist/packages/backend/tsconfig.json'
| opts { required: false }
11 — nexus:start-module create start module
1 — nexus:start-module created
| content '// GENERATED NEXUS START MODULE\n\n\n\nprocess.env.NEXUS_SHOULD_GENERATE_ARTIFACTS = \'true\'process.env.NEXUS_DISABLE_SERVER = \'true\'\n\n\nprocess.env.NEXUS_STAGE = \'dev\'\n\n\n// Run framework initialization side-effects\n// Also, import the app for later use\nconst app = require("/Users/emroot/code/catalist/node_modules/nexus/dist/index.js").default\n\n\n// Last resort error handling\nprocess.once(\'uncaughtException\', error => {\n app.log.fatal(\'uncaughtException\', { error: error })\n process.exit(1)\n})\n\nprocess.once(\'unhandledRejection\', error => {\n app.log.fatal(\'unhandledRejection\', { error: error })\n process.exit(1)\n})\n\n\n// package.json is needed for plugin auto-import system.\n// On the Zeit Now platform, builds and dev copy source into\n// new directory. Copying follows paths found in source. Give one here\n// to package.json to make sure Zeit Now brings it along.\nrequire(\'/Users/emroot/code/catalist/packages/backend/package.json\')\n\n\n// Import the user\'s schema modules\n \nimport \'/Users/emroot/code/catalist/packages/backend/src/graphql/collection\'\nimport \'/Users/emroot/code/catalist/packages/backend/src/graphql/inputs\'\nimport \'/Users/emroot/code/catalist/packages/backend/src/graphql/list\'\nimport \'/Users/emroot/code/catalist/packages/backend/src/graphql/listItem\'\nimport \'/Users/emroot/code/catalist/packages/backend/src/graphql/mutation\'\nimport \'/Users/emroot/code/catalist/packages/backend/src/graphql/providerItem\'\nimport \'/Users/emroot/code/catalist/packages/backend/src/graphql/providerItemAttribute\'\nimport \'/Users/emroot/code/catalist/packages/backend/src/graphql/providerSearchResult\'\nimport \'/Users/emroot/code/catalist/packages/backend/src/graphql/query\'\nimport \'/Users/emroot/code/catalist/packages/backend/src/graphql/scalars\'\nimport \'/Users/emroot/code/catalist/packages/backend/src/graphql/types\'\nimport \'/Users/emroot/code/catalist/packages/backend/src/graphql/user\'\n\n\n// Import the user\'s app module\nrequire("/Users/emroot/code/catalist/packages/backend/src/app")\n\n\n// Boot the server if the user did not already.\nif (app.__state.isWasServerStartCalled === false) {\n app.server.start()\n}process.env.NEXUS_DISABLE_SERVER = \'false\''
prisma-client { engineConfig:
prisma-client { cwd: '/Users/emroot/code/catalist/packages/backend',
prisma-client debug: false,
prisma-client datamodelPath:
prisma-client '/Users/emroot/code/catalist/packages/backend/node_modules/@prisma/client/schema.prisma',
prisma-client prismaPath: undefined,
prisma-client datasources: [],
prisma-client generator:
prisma-client { name: 'client',
prisma-client provider: 'prisma-client-js',
prisma-client output:
prisma-client '/Users/emroot/code/catalist/packages/backend/node_modules/@prisma/client',
prisma-client binaryTargets: [Array],
prisma-client config: {} },
prisma-client showColors: false,
prisma-client logLevel: 'info',
prisma-client logQueries: true,
prisma-client env:
prisma-client { DATABASE_URL:
prisma-client 'postgresql://xxxx:xxxx@localhost:5432/prisma?schema=public',
prisma-client DEBUG: '*' },
prisma-client flags: [] } } +0ms
863 — nexus:plugin loaded plugin entrypoints
| validPlugins [ { packageJsonPath:
| '/Users/emroot/code/catalist/node_modules/nexus-plugin-prisma/package.json',
| runtime:
| { module:
| '/Users/emroot/code/catalist/node_modules/nexus-plugin-prisma/dist/runtime.js',
| export: 'plugin' },
| worktime:
| { module:
| '/Users/emroot/code/catalist/node_modules/nexus-plugin-prisma/dist/worktime.js',
| export: 'plugin' },
| testtime:
| { module:
| '/Users/emroot/code/catalist/node_modules/nexus-plugin-prisma/dist/testtime.js',
| export: 'plugin' } } ]
getos { platform: 'darwin', libssl: undefined } +0ms
302 — nexus:plugin loading worktime plugin -- name: 'nexus-plugin-prisma'
0 — nexus:plugin:nexus-plugin-prisma start
1 ● nexus:plugin:nexus-plugin-prisma Running Prisma generators ...
0 — nexus:plugin:nexus-plugin-prisma .env file found. Looked at: /Users/emroot/code/catalist/packages/backend/.env
0 — nexus:plugin:nexus-plugin-prisma loading generators...
getos { platform: 'darwin', libssl: undefined } +0ms
getos { platform: 'darwin', libssl: undefined } +1ms
(node:61796) ExperimentalWarning: The fs.promises API is experimental
download { cachedFile:
download '/Users/emroot/.cache/prisma/master/2accb9c7eacdc984874eaeb63377fe705dfd3203/darwin/query-engine' } +0ms
download { cachedFileSize: 16570608, targetFileSize: 16570608 } +1ms
download Getting version of /Users/emroot/code/catalist/node_modules/@prisma/sdk/query-engine-darwin. Result: { command:
'/Users/emroot/code/catalist/node_modules/@prisma/sdk/query-engine-darwin --version',
exitCode: 0,
stdout: 'prisma 2accb9c7eacdc984874eaeb63377fe705dfd3203',
stderr: '',
all: undefined,
failed: false,
timedOut: false,
isCanceled: false,
killed: false } +17ms
download Getting version of /Users/emroot/code/catalist/node_modules/@prisma/sdk/query-engine-darwin. Result: prisma 2accb9c7eacdc984874eaeb63377fe705dfd3203 +0ms
download { works: true } +0ms
download { needsToBeDownloaded: false } +0ms
getGenerators { binaryPathsWithEngineType:
getGenerators { 'query-engine':
getGenerators { darwin:
getGenerators '/Users/emroot/code/catalist/node_modules/@prisma/sdk/query-engine-darwin' } } } +0ms
engineCommands getDMMF, override prismaPath = /Users/emroot/code/catalist/node_modules/@prisma/sdk/query-engine-darwin +0ms
engineCommands getConfig, override prismaPath = /Users/emroot/code/catalist/node_modules/@prisma/sdk/query-engine-darwin +41ms
getos { platform: 'darwin', libssl: undefined } +76ms
{ prismaClientDir:
'/Users/emroot/code/catalist/packages/backend/node_modules/@prisma/client' }
getGenerators { outputPath:
getGenerators '/Users/emroot/code/catalist/packages/backend/node_modules/@prisma/client',
getGenerators generatorPath:
getGenerators '/Users/emroot/code/catalist/packages/backend/node_modules/@prisma/client/generator-build/index.js' } +59ms
Generator:/Users/emroot/code/catalist/packages/backend/node_modules/@prisma/client/generator-build/index.js Sending "getManifest" rpc to generator +0ms
getGenerators Resolving based on paths to /Users/emroot/code/catalist/packages/backend/node_modules/@prisma/client +211ms
getos { platform: 'darwin', libssl: undefined } +214ms
download { cachedFile:
download '/Users/emroot/.cache/prisma/master/2accb9c7eacdc984874eaeb63377fe705dfd3203/darwin/query-engine' } +271ms
download { cachedFile:
download '/Users/emroot/.cache/prisma/master/2accb9c7eacdc984874eaeb63377fe705dfd3203/debian-openssl-1.1.x/query-engine' } +0ms
download { cachedFileSize: 16570608, targetFileSize: 16570608 } +0ms
download { cachedFileSize: 19893080, targetFileSize: 19893080 } +4ms
download { needsToBeDownloaded: false } +0ms
download Getting version of /Users/emroot/code/catalist/node_modules/@prisma/sdk/query-engine-darwin. Result: { command:
'/Users/emroot/code/catalist/node_modules/@prisma/sdk/query-engine-darwin --version',
exitCode: 0,
stdout: 'prisma 2accb9c7eacdc984874eaeb63377fe705dfd3203',
stderr: '',
all: undefined,
failed: false,
timedOut: false,
isCanceled: false,
killed: false } +11ms
download Getting version of /Users/emroot/code/catalist/node_modules/@prisma/sdk/query-engine-darwin. Result: prisma 2accb9c7eacdc984874eaeb63377fe705dfd3203 +0ms
download { works: true } +0ms
download { needsToBeDownloaded: false } +0ms
308 — nexus:plugin:nexus-plugin-prisma generators loaded.
0 — nexus:plugin:nexus-plugin-prisma generating
| name 'Prisma Client'
| instanceName 'client'
| output '/Users/emroot/code/catalist/packages/backend/node_modules/@prisma/client'
Generator:/Users/emroot/code/catalist/packages/backend/node_modules/@prisma/client/generator-build/index.js Sending "generate" rpc to generator +22ms
__dirname /Users/emroot/code/catalist/packages/backend/node_modules/@prisma/client/generator-build
/Users/emroot/code/catalist/packages/backend/node_modules/@prisma/client/generator-build
2020-04-13T20:15:35.378Z generateClient makeDir: /Users/emroot/code/catalist/packages/backend/node_modules/@prisma/client
2020-04-13T20:15:35.383Z engineCommands Getting version of /Users/emroot/code/catalist/node_modules/@prisma/sdk/query-engine-darwin
2020-04-13T20:15:35.389Z engineCommands Getting version of /Users/emroot/code/catalist/packages/backend/node_modules/@prisma/client/runtime/query-engine-darwin
2020-04-13T20:15:35.401Z generateClient Getting hashes took 18ms
2020-04-13T20:15:35.402Z generateClient Skipping /Users/emroot/code/catalist/node_modules/@prisma/sdk/query-engine-darwin to /Users/emroot/code/catalist/packages/backend/node_modules/@prisma/client/runtime/query-engine-darwin as both files have md5 hash prisma 2accb9c7eacdc984874eaeb63377fe705dfd3203
2020-04-13T20:15:35.402Z engineCommands Getting version of /Users/emroot/code/catalist/node_modules/@prisma/sdk/query-engine-debian-openssl-1.1.x
2020-04-13T20:15:35.404Z engineCommands Getting version of /Users/emroot/code/catalist/packages/backend/node_modules/@prisma/client/runtime/query-engine-debian-openssl-1.1.x
2020-04-13T20:15:35.409Z generateClient Copying /Users/emroot/code/catalist/node_modules/@prisma/sdk/query-engine-debian-openssl-1.1.x to /Users/emroot/code/catalist/packages/backend/node_modules/@prisma/client/runtime/query-engine-debian-openssl-1.1.x
115 — nexus:plugin:nexus-plugin-prisma done generating
| name 'Prisma Client'
| instanceName 'client'
| output '/Users/emroot/code/catalist/packages/backend/node_modules/@prisma/client'
1 — nexus:compiler config file search result
| fileName 'tsconfig.json'
| configPath '/Users/emroot/code/catalist/packages/backend/tsconfig.json'
| opts { required: true }
7 — nexus:compiler Create TypeScript program
1526 — nexus:build Compiling a development build for typegen
1185 — nexus:start-module create start module
1 — nexus:start-module created
| content '// GENERATED NEXUS START MODULE\n\n\n\nprocess.env.NEXUS_SHOULD_GENERATE_ARTIFACTS = \'true\'\n\n\n// Run framework initialization side-effects\n// Also, import the app for later use\nconst app = require("nexus").default\n\n\n// Last resort error handling\nprocess.once(\'uncaughtException\', error => {\n app.log.fatal(\'uncaughtException\', { error: error })\n process.exit(1)\n})\n\nprocess.once(\'unhandledRejection\', error => {\n app.log.fatal(\'unhandledRejection\', { error: error })\n process.exit(1)\n})\n\n\n// package.json is needed for plugin auto-import system.\n// On the Zeit Now platform, builds and dev copy source into\n// new directory. Copying follows paths found in source. Give one here\n// to package.json to make sure Zeit Now brings it along.\nrequire(\'../../package.json\')\n\n\n// Import the user\'s schema modules\n \nimport \'./graphql/collection\'\nimport \'./graphql/inputs\'\nimport \'./graphql/list\'\nimport \'./graphql/listItem\'\nimport \'./graphql/mutation\'\nimport \'./graphql/providerItem\'\nimport \'./graphql/providerItemAttribute\'\nimport \'./graphql/providerSearchResult\'\nimport \'./graphql/query\'\nimport \'./graphql/scalars\'\nimport \'./graphql/types\'\nimport \'./graphql/user\'\n\n\n// Import the user\'s app module\nrequire("./app")\n\n\n// Statically import runtime plugins for tree-shaking\nimport { plugin as plugin_0 } from \'nexus-plugin-prisma/dist/runtime\'\n\n\n// Boot the server if the user did not already.\nif (app.__state.isWasServerStartCalled === false) {\n app.server.start()\n}'
0 — nexus:start-module Transpiling start module
6 — nexus:build Writing start module to disk
3 ● nexus:build Running typegen & extracting types from addToContext calls
1 — nexus:add-to-context-extractor got app source files
| count 62
| files [ '/Users/emroot/code/catalist/packages/backend/src/amazon.ts',
| '/Users/emroot/code/catalist/packages/backend/src/types.ts',
| '/Users/emroot/code/catalist/packages/backend/src/utils/authUtils.ts',
| '/Users/emroot/code/catalist/packages/backend/src/hooks/useAuthentication.ts',
| '/Users/emroot/code/catalist/packages/backend/src/middlewares/useAppleStrategy.ts',
| '/Users/emroot/code/catalist/packages/backend/src/middlewares/useGoogleStrategy.ts',
| '/Users/emroot/code/catalist/packages/backend/src/middlewares/useRefreshToken.ts',
| '/Users/emroot/code/catalist/packages/backend/src/app.ts',
| '/Users/emroot/code/catalist/packages/backend/src/redis.ts',
| '/Users/emroot/code/catalist/packages/backend/src/admin/providerItem.ts',
| '/Users/emroot/code/catalist/packages/backend/src/utils/requestUtils.ts',
| '/Users/emroot/code/catalist/packages/backend/src/types/AppleMusicApi.d.ts',
| '/Users/emroot/code/catalist/packages/backend/src/secrets/AppleMusicApiSecrets.ts',
| '/Users/emroot/code/catalist/packages/backend/src/utils/getAppleMusicToken.ts',
| '/Users/emroot/code/catalist/packages/backend/src/apis/AppleMusicApi.ts',
| '/Users/emroot/code/catalist/packages/backend/src/types/GoogleBookApi.d.ts',
| '/Users/emroot/code/catalist/packages/backend/src/apis/GoogleBooksApi.ts',
| '/Users/emroot/code/catalist/packages/backend/src/types/OmdbApi.d.ts',
| '/Users/emroot/code/catalist/packages/backend/src/secrets/OmdbApiKey.ts',
| '/Users/emroot/code/catalist/packages/backend/src/apis/IgdbApi.ts',
| '/Users/emroot/code/catalist/packages/backend/src/types/JustWatch.d.ts',
| '/Users/emroot/code/catalist/packages/backend/src/apis/JustWatchApi.ts',
| '/Users/emroot/code/catalist/packages/backend/src/secrets/TheMovieDatabaseApiKey.ts',
| '/Users/emroot/code/catalist/packages/backend/src/types/TheMovieDatabaseApi.d.ts',
| '/Users/emroot/code/catalist/packages/backend/src/secrets/ListenNotesApiKey.ts',
| '/Users/emroot/code/catalist/packages/backend/src/apis/ListenNotesApi.ts',
| '/Users/emroot/code/catalist/packages/backend/src/apis/OmdbApi.ts',
| '/Users/emroot/code/catalist/packages/backend/src/apis/TheMovieDatabaseApi.ts',
| '/Users/emroot/code/catalist/packages/backend/src/graphql/collection.ts',
| '/Users/emroot/code/catalist/packages/backend/src/graphql/inputs.ts',
| '/Users/emroot/code/catalist/packages/backend/src/types/index.d.ts',
| '/Users/emroot/code/catalist/packages/backend/src/graphql/list.ts',
| '/Users/emroot/code/catalist/packages/backend/src/types/ListenNotesApi.d.ts',
| '/Users/emroot/code/catalist/packages/backend/src/schema/Types.ts',
| '/Users/emroot/code/catalist/packages/backend/src/utils/providerUtils.ts',
| '/Users/emroot/code/catalist/packages/backend/src/utils/providerItemUtils.ts',
| '/Users/emroot/code/catalist/packages/backend/src/graphql/listItem.ts',
| '/Users/emroot/code/catalist/packages/backend/src/graphql/mutation.ts',
| '/Users/emroot/code/catalist/packages/backend/src/graphql/providerItem.ts',
| '/Users/emroot/code/catalist/packages/backend/src/graphql/providerItemAttribute.ts',
| '/Users/emroot/code/catalist/packages/backend/src/graphql/providerSearchResult.ts',
| '/Users/emroot/code/catalist/packages/backend/src/graphql/query.ts',
| '/Users/emroot/code/catalist/packages/backend/src/graphql/scalars.ts',
| '/Users/emroot/code/catalist/packages/backend/src/graphql/types.ts',
| '/Users/emroot/code/catalist/packages/backend/src/graphql/user.ts',
| '/Users/emroot/code/catalist/packages/backend/src/schema/Collection.ts',
| '/Users/emroot/code/catalist/packages/backend/src/schema/Inputs.ts',
| '/Users/emroot/code/catalist/packages/backend/src/schema/List.ts',
| '/Users/emroot/code/catalist/packages/backend/src/schema/ListItem.ts',
| '/Users/emroot/code/catalist/packages/backend/src/schema/Mutation.ts',
| '/Users/emroot/code/catalist/packages/backend/src/schema/ProviderItem.ts',
| '/Users/emroot/code/catalist/packages/backend/src/schema/ProviderItemAttribute.ts',
| '/Users/emroot/code/catalist/packages/backend/src/schema/ProviderSearchResult.ts',
| '/Users/emroot/code/catalist/packages/backend/src/schema/Query.ts',
| '/Users/emroot/code/catalist/packages/backend/src/schema/Scalars.ts',
| '/Users/emroot/code/catalist/packages/backend/src/schema/User.ts',
| '/Users/emroot/code/catalist/packages/backend/src/schema/admin/ProviderItem.ts',
| '/Users/emroot/code/catalist/packages/backend/src/schema/admin/index.ts',
| '/Users/emroot/code/catalist/packages/backend/src/secrets/GooglePlacesApiKey.ts',
| '/Users/emroot/code/catalist/packages/backend/src/secrets/TrefleApiKey.ts',
| '/Users/emroot/code/catalist/packages/backend/src/secrets/YelpApiKey.ts',
| '/Users/emroot/code/catalist/packages/backend/src/types/Provider.ts' ]
3 — nexus:add-to-context-extractor found call -- text: 'addToContext'
17 — nexus:add-to-context-extractor found call arg
| text 'req => ({\n auth: useAuthentication({ prisma: prismaClient, request: req }),\n db: prismaClient,\n})'
0 — nexus:add-to-context-extractor processing prop -- name: 'auth'
62 — nexus:add-to-context-extractor found prop type alias symbol? -- found: false
11 — nexus:add-to-context-extractor found prop type symbol? -- found: true
0 — nexus:add-to-context-extractor found name? -- name: 'Promise'
1 — nexus:add-to-context-extractor processing prop -- name: 'db'
0 — nexus:add-to-context-extractor found prop type alias symbol? -- found: false
1 — nexus:add-to-context-extractor found prop type symbol? -- found: true
0 — nexus:add-to-context-extractor found name? -- name: 'PrismaClient'
13 — nexus:add-to-context-extractor finished compiler extension processing
| contextTypeContributions { typeImports: [],
| types:
| [ '{ auth: Promise<AuthContext>; db: PrismaClient<{ log?: undefined; } | { log: ("info" | "query" | "warn")[]; }, never>; }' ] }
1 — nexus:typegen start
express:application set "x-powered-by" to true +0ms
express:application set "etag" to 'weak' +1ms
express:application set "etag fn" to [Function: generateETag] +1ms
express:application set "env" to 'development' +0ms
express:application set "query parser" to 'extended' +0ms
express:application set "query parser fn" to [Function: parseExtendedQueryString] +0ms
express:application set "subdomain offset" to 2 +0ms
express:application set "trust proxy" to false +1ms
express:application set "trust proxy fn" to [Function: trustNone] +0ms
express:application booting in development mode +0ms
express:application set "view" to [Function: View] +0ms
express:application set "views" to '/Users/emroot/code/catalist/packages/backend/views' +0ms
express:application set "jsonp callback name" to 'callback' +0ms
493 ✕ app uncaughtException
| error { Error: Cannot find module './graphql/collection'
| at Function.Module._resolveFilename (internal/modules/cjs/loader.js:580:15)
| at Function.Module._load (internal/modules/cjs/loader.js:506:25)
| at Module.require (internal/modules/cjs/loader.js:636:17)
| at require (internal/modules/cjs/helpers.js:20:18)
| at Object.<anonymous> (/Users/emroot/code/catalist/packages/backend/node_modules/.build/index.js:23:1)
| at Module._compile (internal/modules/cjs/loader.js:688:30)
| at Object.Module._extensions..js (internal/modules/cjs/loader.js:699:10)
| at Module.load (internal/modules/cjs/loader.js:598:32)
| at tryModuleLoad (internal/modules/cjs/loader.js:537:12)
| at Function.Module._load (internal/modules/cjs/loader.js:529:3) code: 'MODULE_NOT_FOUND' }
644 ✕ nexus:build failed to generate artifacts
| error Error:
| Nexus artifact generation failed with exit code "1". The following stderr was captured:
|
| null
|
| at Object.generateArtifacts (/Users/emroot/code/catalist/node_modules/nexus/src/lib/build/artifact-generation.ts:30:11)
| at Object.buildNexusApp (/Users/emroot/code/catalist/node_modules/nexus/src/lib/build/build.ts:86:5)
using yarn workspace
@jasonkuhrt I see that you have replicated both the issue and my setup perfectly. It also seems like you are knees deep in the process of finding a good solution.
Unfortunately, I don’t feel like I have a lot more to offer in this regard at the moment, but let me know in case I can provide any additional information.
Thanks @DerJacques! Yeah we took the opportunity to make Nexus work with tsconfig much better than before. We simply cannot abstract it for the time being https://github.com/graphql-nexus/nexus/issues/659.
Should this fix usage with yarn monorepos? I am trying to run nexus build
, but I am running into this error:
{"level":60,"time":1587776499120,"pid":140,"hostname":"cbd72f44fc43","path":["app"],"context":{"error":{"code":"MODULE_NOT_FOUND","requireStack":["/home/node/app/packages/server/node_modules/.build/index.js"]}},"event":"uncaughtException","v":1}
{"level":60,"time":1587776499155,"pid":125,"hostname":"cbd72f44fc43","path":["nexus","build"],"context":{"error":{}},"event":"failed to generate artifacts","v":1}
I am using TS path aliases with require("tsconfig-paths/register")
at top of app.ts
.
Any ideas? Thanks!
@dodas a new issue for your case would be most welcome. #530 is still open and https://github.com/dividab/tsconfig-paths hasn't be factored into our thinking yet.
Package.json
Nexus Report
Somehow when I run
npx nexus report
I get the following error:Screenshot
Description
The real problem tho is when I run
npx nexus build
I get the following error:My graphql directory is under
src/graphql
.