You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Angular CLI v14/v15执行ng new未生成.gitignore和.editorconfig问题

Angular CLI 创建项目时.gitignore和.editorconfig文件缺失问题解决
  • 检查系统隐藏文件设置:这两个文件本身属于隐藏文件,Windows需在文件夹选项中开启「显示隐藏的文件、文件夹和驱动器」;macOS按下Cmd + Shift + .即可显示隐藏文件,确认文件是否只是未显示而非未创建。
  • 手动添加文件:
    • 创建.gitignore文件,填入Angular项目默认忽略规则:
      # See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
      
      # dependencies
      /node_modules
      /.pnp
      .pnp.js
      
      # testing
      /coverage
      
      # production
      /dist
      /dist-ssr
      /*.local
      
      # misc
      .DS_Store
      .eslintcache
      *.pem
      
      # debug
      npm-debug.log*
      yarn-debug.log*
      yarn-error.log*
      pnpm-debug.log*
      
      # IDEs and editors
      .idea/
      .project
      .classpath
      .c9/
      *.launch
      .settings/
      *.sublime-project
      *.sublime-workspace
      .vscode/*
      !.vscode/extensions.json
      .vscode/*.code-workspace
      *.swp
      *.swo
      
      # IDE - VSCode
      .vscode/extensions.json
      .vscode/*.code-workspace
      .vscode/launch.json
      .vscode/tasks.json
      .vscode/settings.json
      
    • 创建.editorconfig文件,填入通用配置:
      # Editor configuration, see https://editorconfig.org
      root = true
      
      [*]
      charset = utf-8
      indent_style = space
      indent_size = 2
      end_of_line = lf
      trim_trailing_whitespace = true
      insert_final_newline = true
      
      [*.md]
      max_line_length = off
      trim_trailing_whitespace = false
      
  • 清理CLI缓存后重试:执行npm cache clean --force,之后重新运行ng new <project_name>并选择默认选项。
  • 确认文件夹权限:确保项目所在目录具备读写权限,避免CLI无法写入文件。

内容的提问来源于stack exchange,提问作者Sam

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.28 04:04:56