unbuild
unbuild copied to clipboard
some ts error
There some errors when I npx unbuild
src/index.ts(1,8): error TS1259: Module '"/path/to/node_modules/@types/express/index"' can only be default-imported using the 'allowSyntheticDefaultImports' flag?
why and what shoud I do?
I was going to take a look at this issue of yours but since there is no minimal recreation, please provide one 🤙🏼
There is my package.json~
{
"name": "test",
"version": "1.0.0",
"description": "",
"scripts": {
"dev": "tsx watch ./src/app.ts",
"build": "unbuild",
"prepack": "unbuild",
"release": "bumpp && npm publish"
},
"type": "module",
"exports": {
".": {
"import": "./dist/index.mjs",
"require": "./dist/index.cjs"
}
},
"main": "./dist/index.cjs",
"types": "./dist/index.d.ts",
"files": [
"dist"
],
"repository": {
"type": "git",
"url": ""
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"express": "^4.18.1"
},
"devDependencies": {
"@types/express": "^4.17.14",
"bumpp": "^8.2.1",
"tsx": "^3.9.0",
"typescript": "^4.8.3",
"unbuild": "^0.8.11"
}
}
You can always configure allowSyntheticDefaultImports
in your tsconfig. But you also should probably not import from @types/express
- just import the type from express
.