Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Reactjs Heroku部署失败-无法导入Sass文件_Reactjs_Heroku_Node Sass - Fatal编程技术网

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

Reactjs Heroku部署失败-无法导入Sass文件,reactjs,heroku,node-sass,Reactjs,Heroku,Node Sass,我试图使用Heroku进行部署,但在导入sass文件时,我遇到了一个关于节点sass的错误 这似乎是节点sass的一个常见问题,但我无法找到导入scss文件导致该问题的原因。我已重新安装了节点sass,但没有任何帮助 //package.json { "name": "crown-clothing", "version": "0.1.0", "private": true, "dependencies": { "firebase": "^6.3.5", "node

我试图使用Heroku进行部署,但在导入sass文件时,我遇到了一个关于节点sass的错误

这似乎是节点sass的一个常见问题,但我无法找到导入scss文件导致该问题的原因。我已重新安装了节点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文件的导入是导致问题的原因。

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

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

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

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

  • 安装node sass(我已经安装了),然后将我的git存储库更新为最新版本的应用程序。成功了


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

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

  • 安装node sass(我已经安装了),然后将我的git存储库更新为最新版本的应用程序。成功了