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

Angular 5与Bootstrap 4版本兼容问题及npm启动报错求助

解决Angular 5 + Bootstrap 4开发中npm start的TypeScript依赖报错问题

Hey there! Let's get this sorted out for you. The error you're seeing is pretty straightforward—your project is missing the local TypeScript package that @ngtools/webpack (which Angular uses under the hood) requires, and it's likely a version compatibility mismatch between Angular 5 and your dependencies. Here's how to fix it step by step:

1. Install the correct TypeScript version for Angular 5

Angular 5 is compatible with TypeScript 2.4.2 to 2.6.x (we'll go with 2.6.2, a stable, recommended version for Angular 5). Run this command in your project root to install it locally as a dev dependency:

npm install typescript@~2.6.2 --save-dev

2. Verify the installation

Check if TypeScript is now properly installed in your project:

npm ls typescript

You should see the version 2.6.2 listed under your project's dependencies.

3. If issues persist, clean and reinstall dependencies

Sometimes cached files or corrupted node_modules can cause problems. Follow these steps:

  • Delete the node_modules folder:
    # On macOS/Linux
    rm -rf node_modules
    
    # On Windows Command Prompt
    rd /s /q node_modules
    
  • Delete the package-lock.json file:
    # On macOS/Linux
    rm package-lock.json
    
    # On Windows Command Prompt
    del package-lock.json
    
  • Clear npm's cache:
    npm cache clean --force
    
  • Reinstall all dependencies:
    npm install
    

4. Addressing the version mismatch warning

The warning about version mismatch can be suppressed with the command mentioned in the error:

ng set --global warnings.versionMismatch=false

But I'd recommend fixing the underlying dependency versions first instead of just hiding the warning—this ensures your project stays stable.

A quick note on compatibility: Your Node 8.11.1 and npm 5.6.0 versions are actually compatible with Angular 5, so the main issue here was definitely the missing/mismatched TypeScript package.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.21 08:33:39