17.Node项目使用@代替根目录
2021-07-03 本文已影响0人
笑着字太黑
原文地址:module-alias - npm (npmjs.com)
Install:
npm i --save module-alias
Usage:
Add your custom configuration to your package.json (in your application's root)
"_moduleAliases": { "@": ".", "api": "./api" // 你可以使用api代替./api }, "_moduleDirectories": ["node_modules_custom"]
Then add this line at the very main file of your app, before any code
require('module-alias/register')