Closed kaihaase closed 2 years ago
These changes are documented in the changelog and and GitHub release descriptions, and are discussed in multiple past issues, but here is what you need to do to get going:
- import { FileUpload, GraphQLUpload } from 'graphql-upload';
+ import GraphQLUpload from 'graphql-upload/GraphQLUpload.js';
+ import type { FileUpload } from 'graphql-upload/processRequest.js';
- import { graphqlUploadExpress } from 'graphql-upload';
+ import graphqlUploadExpress from 'graphql-upload/graphqlUploadExpress.js';
Make sure your TypeScript config has:
{
"compilerOptions": {
"allowJs": true,
"maxNodeModuleJsDepth": 10,
"module": "nodenext"
}
}
Hope that helps :)
@jaydenseric Thank you very much for your quick support. I have left the TypeScript configuration module in the project on commonjs
, because otherwise there are problems with other packages. Your hints about the imports helped me a lot though.
Hi @jaydenseric !
Is there a way to make it work without having to use "module": "nodenext"
?
@xerstom if you are importing modern ESM packages in a Node.js project, it's expected and reasonable that you have to configure TypeScript to resolve imports the modern Node.js way. You question is more a general usage/config question about TypeScript that is better asked in a TypeScript community space.
You might be able to use "module": "node16"
if your project is not using top level await
. You also might be able to do something different with module
if you set moduleResolution
to node16
or nodenext
, but I'm not sure it's a good idea or will work.
I still have the error
import GraphQLUpload from 'graphql-upload/GraphQLUpload.js';
Cannot find module 'graphql-upload/GraphQLUpload.js' or its corresponding type declarations.
My tsconfig.json { "compilerOptions": { "module": "commonjs", "declaration": true, "removeComments": true, "emitDecoratorMetadata": true, "experimentalDecorators": true, "esModuleInterop": true, "target": "es2017", "sourceMap": true, "outDir": "./dist", "baseUrl": "./", "incremental": true, "skipLibCheck": true, "strictNullChecks": false, "noImplicitAny": false, "strictBindCallApply": false, "forceConsistentCasingInFileNames": false, "noFallthroughCasesInSwitch": false, "typeRoots": ["./src/typings", "node_modules/@types"] },
"exclude": ["packages", "dist", "node_modules"]
}
Since version 14.0.0 the error message "Cannot find module 'graphql-upload' or its corresponding type declarations" occurs in my TypeScript Project (https://github.com/lenneTech/nest-server). With version 13.0.0 everything runs without problems. Do I need to install additional packages or change anything in the TypeScript configuration?