【发布时间】:2021-03-11 15:24:12
【问题描述】:
我在一个角度项目中使用放大。当我运行命令 ng serve 时出现此错误。
Error: node_modules/@aws-amplify/api-graphql/lib-esm/types/index.d.ts:1:30 - error TS7016: Could not find a declaration file for module 'graphql/error/GraphQLError'. 'C:/Users/Ruwani Indrachapa/Documents/profileApp/profileApp1/node_modules/graphql/error/GraphQLError.js' implicitly has an 'any' type.
Try `npm install @types/graphql` if it exists or add a new declaration (.d.ts) file containing `declare module 'graphql/error/GraphQLError';`
1 import { GraphQLError } from 'graphql/error/GraphQLError';
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
node_modules/@aws-amplify/api-graphql/lib-esm/types/index.d.ts:2:30 - error TS7016: Could not find a declaration file for module 'graphql/language/ast'. 'C:/Users/Ruwani Indrachapa/Documents/profileApp/profileApp1/node_modules/graphql/language/ast.js' implicitly has an 'any' type.
Try `npm install @types/graphql` if it exists or add a new declaration (.d.ts) file containing `declare module 'graphql/language/ast';`
2 import { DocumentNode } from 'graphql/language/ast';
所以我在 src 中创建了一个 index.d.ts 文件并将这一行添加到 index.d.ts
declare module 'graphql/language/ast' { export type DocumentNode = any }
之后我在控制台中收到此错误
Error: node_modules/@aws-amplify/api-graphql/lib-esm/types/index.d.ts:1:30 - error TS7016: Could not find a declaration file for module 'graphql/error/GraphQLError'. 'C:/Users/Ruwani Indrachapa/Documents/profileApp/profileApp1/node_modules/graphql/error/GraphQLError.js' implicitly has an 'any' type.
Try `npm install @types/graphql` if it exists or add a new declaration (.d.ts) file containing `declare module 'graphql/error/GraphQLError';`
1 import { GraphQLError } from 'graphql/error/GraphQLError';
需要将declare module 'graphql/error/GraphQLError 这一行放在单独的文件中,或者我可以在 src 中使用 index.d.ts 吗?
我试过npm i graphql。
在那个浏览器控制台向我显示这个错误之后
core.js:5973 ERROR TypeError: Cannot read property 'viewContainerRef' of undefined
at AuthenticatorComponent.push.XRHW.AuthenticatorComponent.loadComponent (authenticator.factory.js:47)
at AuthenticatorComponent.push.XRHW.AuthenticatorComponent.ngOnInit (authenticator.factory.js:31)
at callHook (core.js:4776)
at callHooks (core.js:4746)
at executeInitAndCheckHooks (core.js:4698)
at refreshView (core.js:9153)
at refreshComponent (core.js:10291)
at refreshChildComponents (core.js:8935)
at refreshView (core.js:9188)
at refreshEmbeddedViews (core.js:10245)
帮我解决这个问题。
【问题讨论】:
标签: javascript angular graphql aws-amplify