前端工程化-有些问题记录

212 阅读1分钟

npm

1、npm run build 报错

Command was killed with SIGABRT (Aborted): vite build --mode dev

  • npm cache clean --force
  • export NODE_OPTIONS=--max_old_space_size=4096
  • vite build --mode dev --debug

在执行就好了

tsx

1、Unterminated regular expression literal

在vue文件使用<script setup lang="tsx">报错Unterminated regular expression literal,提示由于解析器在处理代码时遇到了未终止的正则表达式字面量,但在代码中并没有明显的正则表达式。就应该是tsx代码解析的问题

  • 安装@vitejs/plugin-vue-jsx
  • tsconfig配置
/* tsx支持 */
"jsx": "preserve",
"allowJs": true,
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
  • eslinttrc配置
parser: 'vue-eslint-parser',
parserOptions: {
  parser: "@typescript-eslint/parser",
  ecmaFeatures: {
    jsx: true
  }
},