【发布时间】:2022-01-14 11:52:14
【问题描述】:
我对 Node+Typescript 比较陌生,我有一个文件使用 import { IS_PRODUCTION } from '@/config/config'; 这样导入另一个文件模块,我无法理解 @ 符号是如何导入它的。
需要一些帮助来理解这一点。
谢谢
[编辑]:这是 tsconfig.json
{
"compilerOptions": {
"esModuleInterop": true,
"target": "es2018",
"noImplicitAny": true,
"moduleResolution": "node",
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"sourceMap": true,
"outDir": "build",
"baseUrl": ".",
"paths": {
"@/*": ["./src/*"],
"@@/*": ["./*"]
},
"module": "commonjs",
"skipLibCheck": true
},
"include": ["src/**/*"],
"exclude": ["build", "node_modules"]
}
【问题讨论】:
-
它应该是
@scope/提到的here 的范围 -
你可能有一个打包工具来转换这个前缀(通常是项目根目录),例如如果您使用构建应用程序的框架。 TS 也很可能被配置为理解其
tsconfig.json中的前缀。 -
或者你的项目正在使用import map
-
@在模块说明符中有效,在 Windows、Mac 和 Linux 文件名中有效。
标签: node.js typescript express