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



我尝试使用 Heroku 进行部署,但我收到有关节点 sass、导入 sass 文件的错误。

这似乎是node-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-sass,并在推送到heroku之前推送到github。我不能说它们都是必要的,但它正在工作,并且不必转换和 css 文件类型。

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

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

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

相关内容

  • 没有找到相关文章

最新更新