我的react应用程序在Heroku中运行时无法启动。我使用的是Luke McDonald的启动页面,位于:https://github.com/lukemcdonald/holly-react
下面是我的package.json
脚本部分的外观:
"scripts": {
"build": "npm run build:css && vite build",
"build:css": "postcss styles/tailwind.css -o src/assets/styles.css",
"dev": "concurrently \"npm run dev:css\" \"vite\"",
"dev:css": "postcss styles/tailwind.css -o src/assets/styles.css --watch",
"preview": "vite preview",
"predeploy": "npm run build",
"start": "concurrently \"npm run dev:css\" \"vite\"",
"deploy": "gh-pages -d dist"
},
当我推到heroku时,build 成功。但它启动失败:
app[web.1]: /tmp/start-497558d9.sh: 1: concurrently: not found
heroku[web.1]: Process exited with status 127
heroku[web.1]: State changed from starting to crashed
我同时添加了依赖项,但没有效果
"dependencies": {
"clsx": "^1.1.1",
"firebase": "^9.9.3",
"gh-pages": "^4.0.0",
"postcss-import": "^14.1.0",
"react": "^18.1.0",
"react-dom": "^18.1.0",
"react-router-dom": "^6.3.0",
"scrollreveal": "^4.0.9",
"concurrently": "^7.3.0"
},
"devDependencies": {
"@tailwindcss/forms": "^0.5.2",
"@tailwindcss/typography": "^0.5.2",
"@vitejs/plugin-react": "^1.3.2",
"autoprefixer": "^10.4.7",
"concurrently": "^7.3.0",
"eslint": "^8.16.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-prettier": "^4.0.0",
"eslint-plugin-react": "^7.30.0",
"eslint-plugin-react-hooks": "^4.5.0",
"postcss": "^8.4.14",
"postcss-cli": "^9.1.0",
"prettier": "^2.6.2",
"prettier-plugin-tailwindcss": "^0.1.11",
"tailwindcss": "^3.0.24",
"vite": "^2.9.9"
}
1条答案
按热度按时间d6kp6zgx1#
不要试图在Heroku上运行
concurrently \"npm run dev:css\" \"vite\"
,该命令是为开发环境(如本地计算机)设计的。您可能会尝试提供应用的生产版本,它根本不需要
concurrently
。只需运行npm run preview
,它运行vite preview
,从Vite 3开始,它使用sirv
来提供版本输出目录。但是,您不一定需要使用
vite preview
,您可以使用指向构建输出目录的任何其他HTTP服务器(例如,zeit/serve
或http-server
)。