newbiedev
newbiedev

Reputation: 3596

commonjs--resolver - Failed to resolve entry for package "crypto"

I'm trying to use webtorrent inside my vue chrome extensione. After installation of the package using pnpm i webtorrent I import the library in my project but when I try to build the project I will get this error in console

vite v5.4.10 building for production...
[plugin:vite:resolve] [plugin vite:resolve] Module "dgram" has been externalized for browser compatibility, imported by "/Users/m/Sites/blay/node_modules/.pnpm/[email protected]/node_modules/k-rpc-socket/index.js". See https://vite.dev/guide/troubleshooting.html#module-externalized-for-browser-compatibility for more details.
[plugin:vite:resolve] [plugin vite:resolve] Module "net" has been externalized for browser compatibility, imported by "/Users/m/Sites/blay/node_modules/.pnpm/[email protected]/node_modules/k-rpc-socket/index.js". See https://vite.dev/guide/troubleshooting.html#module-externalized-for-browser-compatibility for more details.
[plugin:vite:resolve] [plugin vite:resolve] Module "dns" has been externalized for browser compatibility, imported by "/Users/m/Sites/blay/node_modules/.pnpm/[email protected]/node_modules/k-rpc-socket/index.js". See https://vite.dev/guide/troubleshooting.html#module-externalized-for-browser-compatibility for more details.
✓ 250 modules transformed.
x Build failed in 1.43s
error during build:
[commonjs--resolver] Failed to resolve entry for package "crypto". The package may have incorrect main/module/exports specified in its package.json.
    at packageEntryFailure (file:///Users/m/Sites/blay/node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected]/node_modules/vite/dist/node/chunks/dep-BWSbWtLw.js:46637:15)
    at resolvePackageEntry (file:///Users/m/Sites/blay/node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected]/node_modules/vite/dist/node/chunks/dep-BWSbWtLw.js:46634:3)
    at tryNodeResolve (file:///Users/m/Sites/blay/node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected]/node_modules/vite/dist/node/chunks/dep-BWSbWtLw.js:46450:16)
    at Object.resolveId (file:///Users/m/Sites/blay/node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected]/node_modules/vite/dist/node/chunks/dep-BWSbWtLw.js:46200:19)
    at file:///Users/m/Sites/blay/node_modules/.pnpm/[email protected]/node_modules/rollup/dist/es/shared/node-entry.js:19913:40
    at async PluginDriver.hookFirstAndGetPlugin (file:///Users/m/Sites/blay/node_modules/.pnpm/[email protected]/node_modules/rollup/dist/es/shared/node-entry.js:19813:28)
    at async resolveId (file:///Users/m/Sites/blay/node_modules/.pnpm/[email protected]/node_modules/rollup/dist/es/shared/node-entry.js:18487:26)
    at async ModuleLoader.resolveId (file:///Users/m/Sites/blay/node_modules/.pnpm/[email protected]/node_modules/rollup/dist/es/shared/node-entry.js:18890:15)
    at async Object.resolveId (file:///Users/m/Sites/blay/node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected]/node_modules/vite/dist/node/chunks/dep-BWSbWtLw.js:12833:10)
    at async PluginDriver.hookFirstAndGetPlugin (file:///Users/m/Sites/blay/node_modules/.pnpm/[email protected]/node_modules/rollup/dist/es/shared/node-entry.js:19813:28)
 ELIFECYCLE  Command failed with exit code 1. 

This is the code I have in my vue script tag

//Import the library
import WebTorrent from 'webtorrent';
//Instantiate the library
const client = new WebTorrent();

Is there something I can do to fix this. I've looked at the node_modules folder but I'm unable to find any crypto folder.

Upvotes: 0

Views: 167

Answers (0)

Related Questions