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

Parcel报错:找不到'tslib'模块,请求技术排查支持

Fixing "Cannot find module 'tslib'" Error with Parcel & Pug

Hey there, sorry you've been stuck on this for two days—let's get this sorted out! The "Cannot find module 'tslib'" error usually pops up because some part of Parcel or its plugins relies on this TypeScript helper library, but it's either missing from your project or a cached issue is messing things up. Here are the steps to fix it:

  • First, install tslib directly
    Even though you didn't explicitly add TypeScript to your project, some Parcel internals or plugins depend on tslib. Run this command to add it as a dev dependency:

    npm install tslib --save-dev
    # Or if you use yarn:
    yarn add tslib --dev
    

    After installing, try running your Parcel command again: parcel src/pug/index.pug --open

  • If that doesn't work, clear Parcel's cache
    Parcel caches build artifacts to speed things up, but sometimes the cache gets corrupted. Delete the cache folder with:

    # Mac/Linux
    rm -rf .parcel-cache
    # Windows Command Prompt
    rd /s /q .parcel-cache
    # Windows PowerShell
    Remove-Item -Recurse -Force .parcel-cache
    

    Then re-run your build command.

  • Still no luck? Refresh your entire dependency tree
    Sometimes node_modules or lock files get messed up. Do a clean reinstall:

    1. Delete the node_modules folder and lock file:
      # Mac/Linux
      rm -rf node_modules package-lock.json
      # Windows Command Prompt
      rd /s /q node_modules && del package-lock.json
      # Windows PowerShell
      Remove-Item -Recurse -Force node_modules; Remove-Item package-lock.json
      
    2. Reinstall all dependencies:
      npm install
      # Or yarn install
      
    3. Try your Parcel command once more.
  • Check your Parcel version
    Older versions of parcel-bundler might have known issues with tslib dependencies. Update to the latest stable version:

    npm install parcel-bundler@latest --save-dev
    

These steps should cover the most common causes of this error. Fingers crossed one of them gets your build working again!

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.21 04:20:37