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

Mac下运行React应用报错module.js:471 throw err求助

解决React启动时"Cannot find module 'are-we-there-yet'"错误

我在Mac上运行React应用时遇到报错,原因是为另一个项目更新Node版本后,切换版本操作失误。尝试卸载重装npm后错误仍存在,且不同方法尝试时错误信息有变化,当前报错提示找不到are-we-there-yet模块,报错日志如下:

> npm start
> module.js:471
> throw err;
>     ^

Error: Cannot find module 'are-we-there-yet'
at Function.Module._resolveFilename (module.js:469:15)
at Function.Module._load (module.js:417:25)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/Users/guadalupeabrile/.nvm/versions/node/v6.9.0/lib/node_modules/npm/node_modules/npmlog/log.js:2:16)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)

我的package.json内容:

{
  "name": "scoda",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@testing-library/jest-dom": "^4.2.4",
    "@testing-library/react": "^9.5.0",
    "@testing-library/user-event": "^7.2.1",
    "aos": "^2.3.4",
    "bootstrap": "^5.0.0",
    "d3-ease": "^2.0.0",
    "dom-helpers": "^5.2.1",
    "fslightbox-react": "^1.4.9",
    "google-map-react": "^2.1.9",
    "gsap": "^3.6.1",
    "html-react-parser": "^1.2.6",
    "lax.js": "^1.2.5",
    "rc-collapse": "^3.1.0",
    "react": "^17.0.2",
    "react-autosize-textarea": "^7.0.0",
    "react-bootstrap": "^1.0.0",
    "react-circular-progressbar": "^2.0.3",
    "react-countdown": "^2.2.1",
    "react-countup": "^4.3.3",
    "react-dom": "^17.0.2",
    "react-icofont": "^1.0.19",
    "react-icons": "^4.2.0",
    "react-id-swiper": "^4.0.0",
    "react-image-lightbox": "^5.1.1",
    "react-masonry-css": "^1.0.16",
    "react-move": "^6.1.0",
    "react-router-dom": "^5.1.2",
    "react-scripts": "^2.1.8",
    "react-scrollspy": "^3.4.2",
    "react-slick": "^0.28.1",
    "react-tabs": "^3.1.0",
    "react-text-loop": "^2.3.0",
    "react-text-rotator": "^1.1.0",
    "react-visibility-sensor": "^5.1.1",
    "shufflejs": "^5.2.3",
    "slick-carousel": "^1.8.1",
    "swiper": "^6.6.1",
    "use-lax": "^4.0.3"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "GENERATE_SOURCEMAP=false react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": "react-app"
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  }
}

解决方案

  • 修复当前Node版本的npm依赖
    报错显示当前使用的是nvm管理的Node v6.9.0,其配套的npm依赖are-we-there-yet缺失。直接重新安装对应版本的npm即可:

    npm install -g npm@3.10.8
    

    (Node v6.9.0官方推荐配套npm版本为3.10.8,版本匹配可避免兼容性问题)

  • 切换到兼容的Node版本
    你的React项目依赖react@17.0.2和react-scripts@2.1.8,Node v6.9.0版本过老,兼容性极差。建议切换到Node 14.x版本(LTS版本,适配性好):

    nvm install 14
    nvm use 14
    

    之后清理项目依赖缓存并重新安装:

    rm -rf node_modules package-lock.json
    npm install
    
  • 重置有问题的Node版本
    如果上述方法无效,可卸载并重新安装Node v6.9.0,修复该版本的npm依赖完整性:

    nvm uninstall 6.9.0
    nvm install 6.9.0
    

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.01 21:01:44