I am trying to publish an npm package, my first ever, in typescript.
Everything works fine, i just upload the transpiled code. This package uses undici internally
However, when installing the package (from local source for now), and running it, i get the error ‘Cannot find module ‘undici’, even though it is listed as a dependency inside the package.json
Package.json:
{
"dependencies": {
"undici": "^6.15.0"
},
"name": "pishock",
"version": "1.0.0",
"description": "A typescript wrapper for the PiShock API",
"main": "dist/PiShock.js",
"devDependencies": {},
"scripts": {
"test": "echo "Error: no test specified" && exit 1"
},
"keywords": [
"shock",
"pishock",
"collar"
],
"author": "Wolvinny <[email protected]>",
"license": "ISC",
"types": "./dist/PiShock.d.ts",
"exports": {
".": {
"import": {
"types": "./dist/PiShock.d.mts",
"default": "./dist/PiShock.js"
},
"require": {
"types": "./dist/PiShock.d.ts",
"default": "./dist/PiShock.js"
}
}
}
}
I’m a bit lost as to why this happens and couldnt really find any info on it. All other things work, typings work, etc
I tried removing the entire node_modules and reinstalling, clean project, clearing npm cache. Nothing worked
Luna is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.