node.js - Heroku 使用 React 和 Tailwind 构建失败

标签 node.js reactjs heroku tailwind-css dev-to-production

我尝试将其部署到 Heroku,这是我在尝试将其推送到 Heroku 时收到的错误。这是我目前遇到的错误。我发现我当前遇到的错误涉及顺风,但我不太确定如何处理它。

       Running heroku-postbuild
       
       > <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="adc8cec2c0c0c8dfcec8ed9c839d839d" rel="noreferrer noopener nofollow">[email protected]</a> heroku-postbuild /tmp/build_1c2bd436
       > NPM_CONFIG_PRODUCTION=false npm install --prefix client && npm run build --prefix client
       
       
       > <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="b8dbd7cadd95d2cbf88a968e968989" rel="noreferrer noopener nofollow">[email protected]</a> postinstall /tmp/build_1c2bd436/client/node_modules/babel-runtime/node_modules/core-js
       > node -e "try{require('./postinstall')}catch(e){}"
       
       
       > <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="4b2824392e6621380b78657d657e" rel="noreferrer noopener nofollow">[email protected]</a> postinstall /tmp/build_1c2bd436/client/node_modules/core-js
       > node -e "try{require('./postinstall')}catch(e){}"
       
       
       > <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="15767a6770387f66386560677055263b233b20" rel="noreferrer noopener nofollow">[email protected]</a> postinstall /tmp/build_1c2bd436/client/node_modules/core-js-pure
       > node -e "try{require('./postinstall')}catch(e){}"
       
       added 1657 packages from 798 contributors and audited 1740 packages in 45.079s
       
       68 packages are looking for funding
         run `npm fund` for details
       
       found 0 vulnerabilities
       
       
       > <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="4427282d212a3004746a756a74" rel="noreferrer noopener nofollow">[email protected]</a> build /tmp/build_1c2bd436/client
       > npm run build:css && react-scripts build
       
       
       > <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="7b1817121e150f3b4b554a554b" rel="noreferrer noopener nofollow">[email protected]</a> build:css /tmp/build_1c2bd436/client
       > postcss src/Assests/tailwind.css -o src/Assests/main.css
       
sh: 1: postcss: not found
npm ERR! code ELIFECYCLE
npm ERR! syscall spawn
npm ERR! file sh
npm ERR! errno ENOENT
npm ERR! <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="d1b2bdb8b4bfa591e1ffe0ffe1" rel="noreferrer noopener nofollow">[email protected]</a> build:css: `postcss src/Assests/tailwind.css -o src/Assests/main.css`
npm ERR! spawn ENOENT
npm ERR! 
npm ERR! Failed at the <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="ccafa0a5a9a2b88cfce2fde2fc" rel="noreferrer noopener nofollow">[email protected]</a> build:css script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR!     /tmp/npmcache.tYOmN/_logs/2020-09-25T00_53_01_969Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="8ae9e6e3efe4fecabaa4bba4ba" rel="noreferrer noopener nofollow">[email protected]</a> build: `npm run build:css && react-scripts build`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the clien<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="c9bd89f9e7f8e7f9" rel="noreferrer noopener nofollow">[email protected]</a> build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR!     /tmp/npmcache.tYOmN/_logs/2020-09-25T00_53_01_990Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="ff9a9c9092929a8d9c9abfced1cfd1cf" rel="noreferrer noopener nofollow">[email protected]</a> heroku-postbuild: `NPM_CONFIG_PRODUCTION=false npm install --prefix client && npm run build --prefix client`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="5237313d3f3f3720313712637c627c62" rel="noreferrer noopener nofollow">[email protected]</a> heroku-postbuild script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR!     /tmp/npmcache.tYOmN/_logs/2020-09-25T00_53_02_014Z-debug.log
-----> Build failed ```

这是我在客户端的 package.json

{
  "name": "client",
  "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",
    "axios": "^0.20.0",
    "http-proxy-middleware": "^1.0.5",
    "react": "^16.13.1",
    "react-dom": "^16.13.1",
    "react-redux": "^7.2.1",
    "react-router-dom": "^5.2.0",
    "react-scripts": "3.4.3",
    "react-stripe-checkout": "^2.6.3",
    "redux": "^4.0.5",
    "redux-thunk": "^2.3.0"
  },
  "scripts": {
    "start": "npm run watch:css && react-scripts start",
    "build": "npm run build:css && react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject",
    "build:css": "postcss src/Assests/tailwind.css -o src/Assests/main.css",
    "watch:css": "postcss src/Assests/tailwind.css -o src/Assests/main.css"
  },
  "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"
    ]
  },
  "devDependencies": {
    "autoprefixer": "^9.8.6",
    "i": "^0.3.6",
    "postcss-cli": "^7.1.2",
    "tailwindcss": "^1.8.9"
  }
}

这是我服务器端的 package.json。

{
  "name": "ecommerce",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "engines": {
    "node": "14.4.0",
    "npm": "6.14.8"
  },
  "scripts": {
    "server": "nodemon server.js",
    "client": "npm run start --prefix client",
    "dev": "concurrently \"npm run server\" \"npm run client\"",
    "heroku-postbuild": "NPM_CONFIG_PRODUCTION=false npm install --prefix client && npm run build --prefix client"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "body-parser": "^1.19.0",
    "concurrently": "^5.3.0",
    "cookie-session": "^1.4.0",
    "express": "^4.17.1",
    "mongoose": "^5.10.7",
    "nodemon": "^2.0.4",
    "passport": "^0.4.1",
    "passport-google-oauth20": "^2.0.0",
    "stripe": "^8.100.0"
  }
}

有什么建议吗? 谢谢!

最佳答案

将它们添加到依赖项而不是devDependency

"autoprefixer": "^9.8.6",
"postcss-cli": "^7.1.2",
"tailwindcss": "^1.8.9"

关于node.js - Heroku 使用 React 和 Tailwind 构建失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64056379/

相关文章:

node.js - 需要将wrappbootstrap主题集成到nodejs Expressjs应用程序中的程序

node.js - 使用 Sequelize 返回的限制和别名字段

reactjs - Material UI Chip数组如何像Angular Chip Input一样使用?

javascript - 将输入值传递给 React 中的 AJAX 请求

node.js - 在 Heroku 上使用 NodeJS 进行 HTML5 音频转换

node.js - 如何使用 Node JS 将 mongoDB 查询记录到终端

javascript - 如何在React中同步操作或者说如何让react js代码逐行运行?

javascript - 奇怪的 heroku 命令错误

ruby-on-rails - 操作 View ::模板::错误(意外标记:运算符 (<))

javascript - 路由整个文件夹及其内容