Heroku部署失败-无法导入Sass文件

时间:2019-08-26 17:45:19

标签: reactjs heroku node-sass

编辑:因此,在尝试了诸如清除Heroku缓存,重新安装节点模型和重新部署似乎不起作用的几件事之后,我采取了以下步骤: 1.将我所有的.css文件更改为.sass文件。 2.安装node-sass(我已经拥有),然后将我的git存储库更新到应用程序的最新版本。 做到了!

我正在尝试使用Heroku进行部署,但是却收到有关node-sass的错误,导入了sass文件。

这似乎是node-sass的常见问题,但是我找不到为什么导入scss文件会导致此问题的原因。我重新安装了node-sass,但是没有帮助。

// package.json

{
  "name": "crown-clothing",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "firebase": "^6.3.5",
    "node-sass": "^4.12.0",
    "react": "^16.8.6",
    "react-dom": "^16.8.6",
    "react-redux": "^7.1.0",
    "react-router-dom": "^5.0.1",
    "react-scripts": "3.0.1",
    "react-stripe-checkout": "^2.6.3",
    "redux": "^4.0.4",
    "redux-logger": "^3.0.6",
    "redux-persist": "^5.10.0",
    "reselect": "^4.0.0"
  },
  "scripts": {
    "start": "BROWSER=firefox 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"
    ]
  }
}


//错误消息

    Creating an optimized production build...
remote:        Failed to compile.
remote:        
remote:        ./src/components/directory/directory.styles.scss
remote:        To import Sass files, you first need to install node-sass.
remote:        Run `npm install node-sass` or `yarn add node-sass` inside your workspace.
remote:        
remote:        
remote: npm ERR! code ELIFECYCLE
remote: npm ERR! errno 1
remote: npm ERR! crown-clothing@0.1.0 build: `react-scripts build`
remote: npm ERR! Exit status 1
remote: npm ERR! 
remote: npm ERR! Failed at the crown-clothing@0.1.0 build script.
remote: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
remote: 
remote: npm ERR! A complete log of this run can be found in:
remote: npm ERR!     /tmp/npmcache.7gDk8/_logs/2019-08-26T17_18_16_441Z-debug.log
remote: 
remote: -----> Build failed
remote:        
remote:        We're sorry this build is failing! You can troubleshoot common issues here:
remote:        https://devcenter.heroku.com/articles/troubleshooting-node-deploys
remote:        
remote:        Some possible problems:
remote:        
remote:        - Node version not specified in package.json
remote:          https://devcenter.heroku.com/articles/nodejs-support#specifying-a-node-js-version
remote:        
remote:        Love,
remote:        Heroku

如您所见,导致问题的原因是sass文件的导入。

2 个答案:

答案 0 :(得分:0)

奇怪的是,我要做的就是删除我的node-modules文件夹,重新安装node-sass,然后在推送到heroku之前推送到github。我不能说它们都是必需的,但是它正在工作,并且不必转换和CSS文件类型。

答案 1 :(得分:0)

因此,在尝试了诸如清除Heroku缓存,重新安装节点模型和重新部署似乎不起作用的几件事之后,我采取了以下步骤:

  • 将我所有的.css文件更改为.sass文件。

  • 安装node-sass(我已经安装过),然后将git存储库更新到该应用程序的最新版本。做到了!