Open Paroca72 opened 1 year ago
"moduleResolution": "Node",
has to be NodeNext
or Node16
("module"
too)
I tried those options for "moduleResolution"
but the other AdminJS imports now give me a different error message:
The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an
ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("@adminjs/express")' call
instead.
I also tried the workaround described in the previous issue https://github.com/SoftwareBrothers/adminjs-typeorm/issues/60 and was still getting the error Cannot find module…
. 🤔
Downgrade to v.4 helped
Downgrade to v.4 helped
I tried that as well and got a bit further, though I don't love that path since 5.0.0 has been out for two and half months with no patches to it. 😬
Either way, I'm having a lot of issues related to styled-components
, which didn't seem to get added as a dependency when I installed AdminJS. Happy to create a separate issue if that's helpful, but I'm wondering if they're somehow related. 🤔
#0 8.254 node_modules/@adminjs/design-system/types/src/atoms/avatar/avatar.d.ts(6,58): error TS2694: Namespace '"node_modules/styled-components/dist/index"' has no exported member 'StyledComponent'.
#0 8.255 node_modules/@adminjs/design-system/types/src/atoms/button/button-css.d.ts(1,21): error TS2307: Cannot find module '@styled-components' or its corresponding type declarations.
@sbassin most if not all of our commercial projects use @adminjs/typeorm
and we've had no issues with typeorm/styled-components after migrating them to the latest versions. It's difficult to help without knowing other details regarding your project setup.
I can appreciate that, @dziraf, and thanks for the reply. What information would be most helpful? I will freely admit to being quite inexperienced regarding many the tsconfig.json
compiler settings. Here's what I have been trying in that file:
{
"compilerOptions": {
"rootDirs": ["./src", "./test"],
"target": "ESNext",
"types": ["node", "jest"],
"forceConsistentCasingInFileNames": true,
"module": "NodeNext",
"moduleResolution": "NodeNext",
"strict": true,
"outDir": "./dist",
"sourceMap": true,
"esModuleInterop": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"strictPropertyInitialization": false,
"baseUrl": ".",
"paths": {
"@/*": ["src/*"],
"@test/*": ["test/*"],
"@test-utils/*": ["test/util/*"],
"@factories": ["factories"],
"@factories/*": ["factories/*"],
"@db/*": ["src/db/*"],
"@models/*": ["src/models/*"],
"@resolvers/*": ["src/resolvers/*"],
"@services/*": ["src/services/*"]
}
}
}
And here are the dependencies in my package.json
file:
"dependencies": {
"@adminjs/express": "^6.0.0",
"@adminjs/typeorm": "^5.0.0",
"@types/express-session": "^1.17.7",
"adminjs": "^7.0.8",
"apollo-server": "^3.12.0",
"apollo-server-express": "^3.12.0",
"auth0": "^3.4.0",
"bcrypt": "^5.1.0",
"chance": "^1.1.11",
"class-validator": "^0.13.2",
"express": "^4.18.2",
"express-jwt": "^8.4.1",
"express-oauth2-jwt-bearer": "^1.5.0",
"gravatar": "^1.8.2",
"jsonwebtoken": "^9.0.1",
"module-alias": "^2.2.3",
"pg": "^8.11.0",
"postgres": "^3.3.5",
"reflect-metadata": "^0.1.13",
"styled-components": "^6.0.3",
"tslog": "3.3.4",
"type-graphql": "^1.1.1",
"typedi": "^0.10.0",
"typeorm": "^0.3.16"
},
Would any more information be valuable?
@sbassin do you have type: "module"
set in your package.json
?
I do not, @dziraf, but I'd be happy to try that later tonight. Thanks.
Well, that seems to have cleared up a lot of the problems I was seeing. I'm still seeing a number of these issues relating to @styled-components
like:
node_modules/@adminjs/design-system/types/src/utils/reset.styles.d.ts:1:21 - error TS2307: Cannot find module '@styled-components' or its corresponding type declarations.
1 import { css } from '@styled-components';
Hello,
I already seen something similar in the "closed" issues where is a workaround but not a solution. Is possible to find a solution for this issue.
Node.js v18.16.0
Package,json
tsconfig.json
Thanks for your help Sam