I am using the toolkit components to create a library using(create-react-library), and the main app which use library also has some toolkit components, when ever i link the library to the main app there is problem with the same : "error Failed to execute 'define' on 'CustomElementRegistry': the name "mgt-mock-provider". The library and the main app work independently they render the graph toolkit components , there is a problem when I do npm link and link to main app Or publish and install the library
Asked
Active
Viewed 218 times
0

Umamaheshwari G
- 3
- 4
1 Answers
1
This is a common toolkit error when incompatible mgt packages are used, and is why "same" name registry error occurs.
In your modules or package.json, I assume you are using React, and therefore a common dependency tree is:
"dependencies": {
"@microsoft/mgt-element": "*",
"@microsoft/mgt-react": "*",
"@microsoft/mgt-msal-provider": "*",
}
This should not include the @microsoft/mgt package as well. See the Npm site for more examples https://www.npmjs.com/package/@microsoft/mgt-react or samples included in the package itself: https://github.com/microsoftgraph/microsoft-graph-toolkit/tree/main/samples/react-app

Nic Vogt
- 261
- 1
- 6
-
Hi Nic Vogt- i tried the above solution with in the main app package. - { "@microsoft/mgt-element": "*", "@microsoft/mgt-react": "*"} and the library we created to be used in the main app has - { "@microsoft/mgt-element": "*", "@microsoft/mgt-react": "*"} when i try to import the library in the main app this is what i get × NotSupportedError: Failed to execute 'define' on 'CustomElementRegistry': the name "mgt-mock-provider" has already been used with this registry – Umamaheshwari G Jan 27 '22 at 05:39
-
@UmamaheshwariG Can you provide us a sample or some more information on the mgt repository, https://github.com/microsoftgraph/microsoft-graph-toolkit/issues/new/choose There must be another collision in your setup somewhere. – Nic Vogt Jan 28 '22 at 17:28
-
here is the link for the information. https://github.com/microsoftgraph/microsoft-graph-toolkit/issues/1496 – Umamaheshwari G Jan 31 '22 at 10:05