Closed matthewmueller closed 4 years ago
Could not reproduce this:
C:\Users\Jan\Documents\throwaway\560
λ prisma2 -v
prisma2@2.0.0-preview023, binary version: d3b0ceed5d87544b9d2decb70e08664f9047bb73
C:\Users\Jan\Documents\throwaway\560
λ prisma2 generate
✔ Created ./package.json
yarn add v1.22.0
warning ..\..\package.json: No license field
info No lockfile found.
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
success Saved lockfile.
success Saved 1 new dependency.
info Direct dependencies
└─ prisma2@2.0.0-preview023
info All dependencies
└─ prisma2@2.0.0-preview023
Done in 13.66s.
yarn add v1.22.0
warning ..\..\package.json: No license field
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
success Saved lockfile.
success Saved 1 new dependency.
info Direct dependencies
└─ @prisma/client@2.0.0-preview023
info All dependencies
└─ @prisma/client@2.0.0-preview023
Done in 1.55s.
✔ Installed the @prisma/client and prisma2 packages in your project
✔ Generated Prisma Client to .\node_modules\@prisma\client in 73ms
You can now start using Prisma Client in your code:
´´´
import { PrismaClient } from '@prisma/client'
// or const { PrismaClient } = require('@prisma/client')
const prisma = new PrismaClient()
´´´
Explore the full API: http://pris.ly/d/client
C:\Users\Jan\Documents\throwaway\560 (my-prisma-project@1.0.0)
λ ts-node index.ts
C:\ProgramData\nvm\v12.6.0\node_modules\ts-node\src\index.ts:245
return new TSError(diagnosticText, diagnosticCodes)
^
TSError: ⨯ Unable to compile TypeScript:
error TS2468: Cannot find global value 'Promise'.
index.ts:4:16 - error TS2705: An async function or method in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your `--lib` option.
4 async function main() {
~~~~
at createTSError (C:\ProgramData\nvm\v12.6.0\node_modules\ts-node\src\index.ts:245:12)
at reportTSError (C:\ProgramData\nvm\v12.6.0\node_modules\ts-node\src\index.ts:249:19)
at getOutput (C:\ProgramData\nvm\v12.6.0\node_modules\ts-node\src\index.ts:357:34)
at Object.compile (C:\ProgramData\nvm\v12.6.0\node_modules\ts-node\src\index.ts:415:32)
at Module.m._compile (C:\ProgramData\nvm\v12.6.0\node_modules\ts-node\src\index.ts:493:43)
at Module._extensions..js (internal/modules/cjs/loader.js:787:10)
at Object.require.extensions.<computed> [as .ts] (C:\ProgramData\nvm\v12.6.0\node_modules\ts-node\src\index.ts:496:12)
at Module.load (internal/modules/cjs/loader.js:643:32)
at Function.Module._load (internal/modules/cjs/loader.js:556:12)
at Function.Module.runMain (internal/modules/cjs/loader.js:839:10)
C:\Users\Jan\Documents\throwaway\560 (my-prisma-project@1.0.0)
λ node index.js
PrismaClientKnownRequestError:
Invalid `console.log(await prisma.users.count()` invocation in
C:\Users\Jan\Documents\throwaway\560\index.js:6:34
2 const prisma = new PrismaClient()
3
4 async function main() {
5 await prisma.connect()
→ 6 console.log(await prisma.users.count())
Authentication failed against database server at `localhost`, the provided database credentials for `m` are not valid.
Please make sure to provide valid database credentials for the database server at `localhost`.
at PrismaClientFetcher.request (C:\Users\Jan\Documents\throwaway\560\node_modules\@prisma\client\index.js:87:17)
at processTicksAndRejections (internal/process/task_queues.js:85:5) {
code: 'P1000',
meta: { database_user: 'm', database_host: 'localhost' }
}
^C
C:\Users\Jan\Documents\throwaway\560 (my-prisma-project@1.0.0)
λ npm install uid
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN my-prisma-project@1.0.0 No description
npm WARN my-prisma-project@1.0.0 No repository field.
+ uid@1.0.0
added 1 package from 1 contributor and audited 3 packages in 1.005s
found 0 vulnerabilities
C:\Users\Jan\Documents\throwaway\560 (my-prisma-project@1.0.0)
λ node index.js
PrismaClientKnownRequestError:
Invalid `console.log(await prisma.users.count()` invocation in
C:\Users\Jan\Documents\throwaway\560\index.js:6:34
2 const prisma = new PrismaClient()
3
4 async function main() {
5 await prisma.connect()
→ 6 console.log(await prisma.users.count())
Authentication failed against database server at `localhost`, the provided database credentials for `m` are not valid.
Please make sure to provide valid database credentials for the database server at `localhost`.
at PrismaClientFetcher.request (C:\Users\Jan\Documents\throwaway\560\node_modules\@prisma\client\index.js:87:17)
at processTicksAndRejections (internal/process/task_queues.js:85:5) {
code: 'P1000',
meta: { database_user: 'm', database_host: 'localhost' }
}
^C
As you can see I had to change the script to index.js
as your reproduction was missing information.
C:\Users\Jan\Documents\throwaway\560 (my-prisma-project@1.0.0)
λ npm -v
6.9.0
C:\Users\Jan\Documents\throwaway\560 (my-prisma-project@1.0.0)
λ npm version
{
'my-prisma-project': '1.0.0',
npm: '6.9.0',
ares: '1.15.0',
brotli: '1.0.7',
cldr: '35.1',
http_parser: '2.8.0',
icu: '64.2',
llhttp: '1.1.4',
modules: '72',
napi: '4',
nghttp2: '1.38.0',
node: '12.6.0',
openssl: '1.1.1c',
tz: '2019a',
unicode: '12.1',
uv: '1.30.1',
v8: '7.5.288.22-node.14',
zlib: '1.2.11'
}
C:\Users\Jan\Documents\throwaway\560 (my-prisma-project@1.0.0)
λ node -v
v12.6.0
Can reproduce:
C:\Users\Jan\Documents\throwaway
λ mkdir 560_3
C:\Users\Jan\Documents\throwaway
λ cd 560_3
C:\Users\Jan\Documents\throwaway\560_3
λ npm init
This utility will walk you through creating a package.json file.
It only covers the most common items, and tries to guess sensible defaults.
See `npm help json` for definitive documentation on these fields
and exactly what they do.
Use `npm install <pkg>` afterwards to install a package and
save it as a dependency in the package.json file.
Press ^C at any time to quit.
package name: (560_3)
version: (1.0.0)
description:
entry point: (index.js)
test command:
git repository:
keywords:
author:
license: (ISC)
About to write to C:\Users\Jan\Documents\throwaway\560_3\package.json:
{
"name": "560_3",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC"
}
Is this OK? (yes)
C:\Users\Jan\Documents\throwaway\560_3 (560_3@1.0.0)
λ
C:\Users\Jan\Documents\throwaway\560_3 (560_3@1.0.0)
λ npm install prisma2 ts-node typescript
> prisma2@2.0.0-preview023 install C:\Users\Jan\Documents\throwaway\560_3\node_modules\prisma2
> node download-build/index.js
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN 560_3@1.0.0 No description
npm WARN 560_3@1.0.0 No repository field.
+ ts-node@8.6.2
+ prisma2@2.0.0-preview023
+ typescript@3.8.3
added 10 packages from 42 contributors and audited 10 packages in 13.072s
found 0 vulnerabilities
C:\Users\Jan\Documents\throwaway\560_3 (560_3@1.0.0)
λ code .
C:\Users\Jan\Documents\throwaway\560_3>"./node_modules/.bin/prisma2" generate
yarn add v1.22.0
warning ..\..\package.json: No license field
info No lockfile found.
warning package-lock.json found. Your project contains lock files generated by tools other than Yarn. It is advised not to mix package managers in order to avoid resolution inconsistencies caused by unsynchronized lock files. To clear this warning, remove package-lock.json.
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
success Saved lockfile.
warning "prisma2" is already in "dependencies". Please remove existing entry first before adding it to "devDependencies".
success Saved 10 new dependencies.
info Direct dependencies
├─ prisma2@2.0.0-preview023
├─ ts-node@8.6.2
└─ typescript@3.8.3
info All dependencies
├─ arg@4.1.3
├─ buffer-from@1.1.1
├─ diff@4.0.2
├─ make-error@1.3.6
├─ prisma2@2.0.0-preview023
├─ source-map-support@0.5.16
├─ source-map@0.6.1
├─ ts-node@8.6.2
├─ typescript@3.8.3
└─ yn@3.1.1
Done in 14.26s.
yarn add v1.22.0
warning ..\..\package.json: No license field
warning package-lock.json found. Your project contains lock files generated by tools other than Yarn. It is advised not to mix package managers in order to avoid resolution inconsistencies caused by unsynchronized lock files. To clear this warning, remove package-lock.json.
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
success Saved lockfile.
success Saved 1 new dependency.
info Direct dependencies
└─ @prisma/client@2.0.0-preview023
info All dependencies
└─ @prisma/client@2.0.0-preview023
Done in 2.04s.
✔ Installed the @prisma/client and prisma2 packages in your project
✔ Generated Prisma Client to .\node_modules\@prisma\client in 90ms
You can now start using Prisma Client in your code:
´´´
import { PrismaClient } from '@prisma/client'
// or const { PrismaClient } = require('@prisma/client')
const prisma = new PrismaClient()
´´´
Explore the full API: http://pris.ly/d/client
C:\Users\Jan\Documents\throwaway\560_3>"./node_modules/.bin/ts-node" index.ts
PrismaClientKnownRequestError:
Invalid `prisma.users.count()` invocation in
C:\Users\Jan\Documents\throwaway\560_3\index.ts:7:36
Authentication failed against database server at `localhost`, the provided database credentials for `m` are not valid.
Please make sure to provide valid database credentials for the database server at `localhost`.
at PrismaClientFetcher.request (C:\Users\Jan\Documents\throwaway\560_3\node_modules\@prisma\client\index.js:87:17)
at processTicksAndRejections (internal/process/task_queues.js:85:5) {
code: 'P1000',
meta: { database_user: 'm', database_host: 'localhost' }
}
^CTerminate batch job (Y/N)? ^C
C:\Users\Jan\Documents\throwaway\560_3>npm install uid
> prisma2@2.0.0-preview023 install C:\Users\Jan\Documents\throwaway\560_3\node_modules\prisma2
> node download-build/index.js
npm WARN 560_3@1.0.0 No description
npm WARN 560_3@1.0.0 No repository field.
+ uid@1.0.0
added 1 package from 1 contributor, removed 1 package, updated 10 packages and audited 11 packages in 12.514s
found 0 vulnerabilities
C:\Users\Jan\Documents\throwaway\560_3>"./node_modules/.bin/ts-node" index.ts
C:\Users\Jan\Documents\throwaway\560_3\node_modules\ts-node\src\index.ts:421
return new TSError(diagnosticText, diagnosticCodes)
^
TSError: ⨯ Unable to compile TypeScript:
index.ts:1:30 - error TS2307: Cannot find module '@prisma/client'.
1 import { PrismaClient } from '@prisma/client'
~~~~~~~~~~~~~~~~
at createTSError (C:\Users\Jan\Documents\throwaway\560_3\node_modules\ts-node\src\index.ts:421:12)
at reportTSError (C:\Users\Jan\Documents\throwaway\560_3\node_modules\ts-node\src\index.ts:425:19)
at getOutput (C:\Users\Jan\Documents\throwaway\560_3\node_modules\ts-node\src\index.ts:530:36)
at Object.compile (C:\Users\Jan\Documents\throwaway\560_3\node_modules\ts-node\src\index.ts:735:32)
at Module.m._compile (C:\Users\Jan\Documents\throwaway\560_3\node_modules\ts-node\src\index.ts:814:43)
at Module._extensions..js (internal/modules/cjs/loader.js:787:10)
at Object.require.extensions.<computed> [as .ts] (C:\Users\Jan\Documents\throwaway\560_3\node_modules\ts-node\src\index.ts:817:12)
at Module.load (internal/modules/cjs/loader.js:643:32)
at Function.Module._load (internal/modules/cjs/loader.js:556:12)
at Function.Module.runMain (internal/modules/cjs/loader.js:839:10)
C:\Users\Jan\Documents\throwaway\560_3>
What is probably happening is that generate uses yarn later the npm install does not pick up and thus remove the @prisma/client from that
Possible reason: https://github.com/prisma/prisma-client-js/issues/561
I think you wanted to close this as well with your commit message @Jolg42
Yes indeed I also wanted to post this: fixed in alpha 920!
Steps to Reproduce
0. Install packages
0.5 Add tsconfig.json
This is a cleaned up result of running
./node_modules/.bin/tsc --init
and changing thetarget
field.1. Start with a working prisma schema
This step can be anything, but here's mine:
2. Run
./node_modules/.bin/prisma2 generate
, get a working clientYou should see
3. Write a script that uses
@prisma/client
Again shouldn't matter but here's mine:
All good.
4. Run
npm install uid
(or any package name)NPM version
Node version
5. Run your script again
To fix this, you need to run
./node_modules/.bin/prisma2 generate
again. This is really disruptive.