繁体   English   中英

安装“node-sass”后,React 应用程序无法编译。 如何修复“未找到模块”错误?

[英]React app fails to compile after installing 'node-sass'. How to fix “Module not found” error?

我已经构建了一个 react.js 应用程序,它在使用 npm install 安装“node-sass”之前运行良好。 当使用 npm 启动时,该应用程序在生产版本中正常运行,但在开发版本中无法编译。 除了“node-sass”之外,任何其他 package 都不会出现此问题

当我将其导入另一台 PC 并在那里安装“node-sass”时,该应用程序运行良好。 我尝试重新安装节点和 npm 但无济于事。 我也已经在全球范围内卸载了 node-sass。

这是我的 package.json:

  "name": "my_app_name",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "gh-pages": "^2.1.1",
    "node-sass": "^4.12.0",
    "react": "^16.10.2",
    "react-dom": "^16.10.2",
    "react-scripts": "3.2.0"
  },
  "scripts": {
    "predeploy": "npm run build",
    "deploy": "npm run build && gh-pages -d build",
    "start": "react-scripts start",
    "build": "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"
    ]
  }
}

这是我不断收到的错误消息:

Failed to compile.

./node_modules/react-dev-utils/formatWebpackMessages.js
Module not found: Can't resolve 'path\to\app\node_modules\babel-preset-react-app\node_modules\@babel\runtime/helpers/slicedToArray' in 'path\to\app\node_modules\react-dev-utils'

全局安装 node-sass,而不是 package。 npm i node-sass

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM