'@metamask/detect-provider is not importing

I am trying to import detectEthereumProvider from '@metamask/detect-provider'.

When inspecting my website with live server open, I get a line saying

Uncaught TypeError: Failed to resolve module specifier "@metamask/detect-provider". Relative references must start with either "/", "./", or "../".

I have installed using npm install @metamask/detect-provider.

My package.json shows "@metamask/detect-provider": "^1.2.0",

It shows up in my node_modules.

In my index.html file, I include this:

<script src="https://unpkg.com/@metamask/detect-provider/dist/detect-provider.min.js"></script>

I am not sure what I have done wrong. If there is any other code I need to show please let me know what to show.



Solution 1:[1]

I have a similar error, I tried npm audit fix --force (twice) and it resolved the issue.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Tom