Closed wojtekKrol closed 2 years ago
Please try uninstalling @types/graphql-upload
; graphql-upload
has it's own types built in now via TypeScript JSDoc comments.
@jaydenseric I've removed it from package.json
and then run npm ci
. Error remains
Does your project TypeScript config have compilerOptions.module
set to nodenext
?
It's set to:
"compilerOptions": {
"module": "commonjs",
...
my other main packages versions:
"apollo-server-core": "^3.9.0",
"apollo-server-express": "3.9.0",
"graphql": "^15.3.0",
in case it's matter
It should be set to nodenext
(or node16
if you want to forbid top level await
) so TypeScript resolves imports and types the modern Node.js way. Also make sure your TypeScript version (both used via CLI, and the one powering VS Code intellisense) is up to date as only recent versions of TypeScript support that mode and appropriately make use of the package.json
exports
field and such.
Still nothing
@wojtekKrol there are several things wrong at once in that screenshot. Firstly, it looks in the bottom left like your TypeScript version is out of date because it's failing to recognise the node16
value. Another thing wrong is you are trying to import something that doesn't exist; use:
import type { FileUpload } from "graphql-upload/processRequest.js";
Another problem you can see in the bottom right is you are attempting to use Node.js to run ESM without using the correct .mjs
file extension, as the error message says.
Okey so let me clarify
In my project I'm using typescript 4.7.2
and node 14.18.3
(because `graphql-upload v15.0.2 supports node >14.17.0)
now I've edited package.json
added at top level as typescript suggest
"type": "module",
and still gets this errors:
this is my tsconfig.json
{
"compilerOptions": {
"target": "es2020",
"module": "node16",
"lib": ["dom", "es6", "es2017", "esnext.asynciterable"],
"outDir": "./dist",
"moduleResolution": "node",
"removeComments": true,
"noImplicitAny": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"noEmitHelpers": true,
"importHelpers": true,
"noImplicitThis": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"allowSyntheticDefaultImports": true,
"allowJs": true,
"esModuleInterop": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"resolveJsonModule": true,
"baseUrl": ".",
"sourceMap": true,
"paths": {
"@/*": ["src/*"],
"@test/*": ["test/*"]
},
"plugins": [
{
"transform": "@zerollup/ts-transform-paths",
"exclude": ["*"]
}
]
},
"exclude": ["node_modules"],
"include": [
"./src/**/*.tsx",
"./src/**/*.ts",
"./src/**/*.js",
"./src/**/*.d.ts",
"./src/**/*.json",
"./src/**/*.json5",
"./test/**/*.ts",
"./src/**/*.csv",
"./node_modules/graphql-upload/*.js"
]
}
Currently because of typescript
version I can not even run ttsc -w
which is wrapper on tsc
because I get errors
@jaydenseric
Without looking at the other settings, "moduleResolution": "node"
is wrong; it's overriding the behavior of "module": "node16"
. Try deleting it.
Have the same issue
Im migrating from apollo v2 to v3 and wanted to update
graphql-upload
and occur this errorMy packages are:
I saw this thread but these solutions do not work for me, could someone tell me how to make it work?