TypeError: (0 , dayjs_1.default) is not a function
TypeError: (0 , dayjs_1.default) is not a function
这是我的 logger.ts
文件,那里发生了错误:
import logger from "pino";
import dayjs from "dayjs";
const log = logger({
prettyPrint: true,
base: {
pid: false,
},
timestamp: () => `,"time":"${dayjs().format()}"`,
});
export default log;
错误:
yarn dev
yarn run v1.22.17
warning package.json: License should be a valid SPDX license expression
warning ..\..\..\..\package.json: No license field
$ ts-node-dev --respawn --transpile-only src/app.ts
[INFO] 19:09:45 ts-node-dev ver. 1.1.8 (using ts-node ver. 9.1.1, typescript ver. 4.6.3)
TypeError: (0 , dayjs_1.default) is not a function
at timestamp (C:\Users\A\Desktop\desktop\base_code\back_bc_node\src\utils\logger.ts:9:37)
at pino (C:\Users\A\Desktop\desktop\base_code\back_bc_node\node_modules\pino\pino.js:147:26)
at Object.<anonymous> (C:\Users\A\Desktop\desktop\base_code\back_bc_node\src\utils\logger.ts:4:19)
at Module._compile (node:internal/modules/cjs/loader:1103:14)
at Module._compile (C:\Users\A\Desktop\desktop\base_code\back_bc_node\node_modules\source-map-support\source-map-support.js:568:25)
at Module.m._compile (C:\Users\A\AppData\Local\Temp\ts-node-dev-hook-15803171947249184.js:69:33)
at Module._extensions..js (node:internal/modules/cjs/loader:1155:10)
at require.extensions.<computed> (C:\Users\A\AppData\Local\Temp\ts-node-dev-hook-15803171947249184.js:71:20)
at Object.nodeDevHook [as .ts] (C:\Users\A\Desktop\desktop\base_code\back_bc_node\node_modules\ts-node-dev\lib\hook.js:63:13)
at Module.load (node:internal/modules/cjs/loader:981:32)
[ERROR] 19:09:46 TypeError: (0 , dayjs_1.default) is not a function
(node:10308) [PINODEP008] PinoWarning: prettyPrint is deprecated, look at https://github.com/pinojs/pino-pretty for alternatives.
(Use `node --trace-warnings ...` to show where the warning was created)
它在我以前的应用程序上工作,但我不知道为什么我的新应用程序会收到此错误?
dayjs 不会导出这样的默认条目;使用 import * as dayjs from 'dayjs'
导入它的所有导出(正如您正在尝试做的那样)
这是我的 logger.ts
文件,那里发生了错误:
import logger from "pino";
import dayjs from "dayjs";
const log = logger({
prettyPrint: true,
base: {
pid: false,
},
timestamp: () => `,"time":"${dayjs().format()}"`,
});
export default log;
错误:
yarn dev
yarn run v1.22.17
warning package.json: License should be a valid SPDX license expression
warning ..\..\..\..\package.json: No license field
$ ts-node-dev --respawn --transpile-only src/app.ts
[INFO] 19:09:45 ts-node-dev ver. 1.1.8 (using ts-node ver. 9.1.1, typescript ver. 4.6.3)
TypeError: (0 , dayjs_1.default) is not a function
at timestamp (C:\Users\A\Desktop\desktop\base_code\back_bc_node\src\utils\logger.ts:9:37)
at pino (C:\Users\A\Desktop\desktop\base_code\back_bc_node\node_modules\pino\pino.js:147:26)
at Object.<anonymous> (C:\Users\A\Desktop\desktop\base_code\back_bc_node\src\utils\logger.ts:4:19)
at Module._compile (node:internal/modules/cjs/loader:1103:14)
at Module._compile (C:\Users\A\Desktop\desktop\base_code\back_bc_node\node_modules\source-map-support\source-map-support.js:568:25)
at Module.m._compile (C:\Users\A\AppData\Local\Temp\ts-node-dev-hook-15803171947249184.js:69:33)
at Module._extensions..js (node:internal/modules/cjs/loader:1155:10)
at require.extensions.<computed> (C:\Users\A\AppData\Local\Temp\ts-node-dev-hook-15803171947249184.js:71:20)
at Object.nodeDevHook [as .ts] (C:\Users\A\Desktop\desktop\base_code\back_bc_node\node_modules\ts-node-dev\lib\hook.js:63:13)
at Module.load (node:internal/modules/cjs/loader:981:32)
[ERROR] 19:09:46 TypeError: (0 , dayjs_1.default) is not a function
(node:10308) [PINODEP008] PinoWarning: prettyPrint is deprecated, look at https://github.com/pinojs/pino-pretty for alternatives.
(Use `node --trace-warnings ...` to show where the warning was created)
它在我以前的应用程序上工作,但我不知道为什么我的新应用程序会收到此错误?
dayjs 不会导出这样的默认条目;使用 import * as dayjs from 'dayjs'
导入它的所有导出(正如您正在尝试做的那样)