我已经按照heroku上的说明进行了几个小时的研究,发现了关于部署到heroku的问题,每当我将存储库推送到heroku时,构建新的包时就会失败。
我正在使用Yarn包管理器,并添加了很多依赖到我的应用程序。我添加了一个依赖与NPM,并禁止选择两个包管理器进行开发。...我已经删除了package-lock.json文件,并更改了package.json与脚本,以根据包管理器,我用我的应用程序。
{
"name": "real-world",
"version": "1",
"description": "MERN",
"main": "app.js",
"author": "Le, Vu Minh",
"license": "MIT",
"scripts": {
"client-install": "yarn --cwd frontend install",
"start": "node ./app.js",
"server": "node ./app.js",
"client": "yarn --cwd ./frontend run start",
"dev": "concurrently \"yarn run server\" \"yarn run client\"",
"heroku-postbuild": "yarn install && yarn --cwd ./frontend install && yarn --cwd ./frontend run build"
},
"engines": {
"node": "10.16.0",
"yarn": "1.19.0"
},
"dependencies": {
"body-parser": "^1.19.0",
"concurrently": "^5.0.0",
"cors": "^2.8.5",
"crypto": "^1.0.1",
"dotenv": "^8.2.0",
"errorhandler": "^1.5.1",
"express": "^4.17.1",
"express-jwt": "^5.3.1",
"express-session": "^1.17.0",
"jshint": "^2.10.2",
"jsonwebtoken": "^8.5.1",
"jwt": "^0.2.0",
"method-override": "^3.0.0",
"mongoose": "^5.7.4",
"morgan": "^1.9.1",
"passport": "^0.4.0",
"passport-local": "^1.0.0",
"serve": "^11.2.0"
},
"devDependencies": {
"nodemon": "^1.19.3"
}
}
这是输出,当我推到heroku大师分支。
remote: -----> Creating runtime environment
remote:
remote: NPM_CONFIG_LOGLEVEL=error
remote: NODE_ENV=production
remote: NODE_MODULES_CACHE=true
remote: NODE_VERBOSE=false
remote:
remote: -----> Installing binaries
remote: engines.node (package.json): 10.16.0
remote: engines.npm (package.json): unspecified (use default)
remote: engines.yarn (package.json): 1.19.0
remote:
remote: Resolving node version 10.16.0...
remote: Downloading and installing node 10.16.0...
remote: Using default npm version: 6.9.0
remote: Resolving yarn version 1.19.0...
remote: Downloading and installing yarn (1.19.0)...
remote: Installed yarn 1.19.0
remote:
remote: -----> Installing dependencies
remote: Installing node modules (yarn.lock)
remote: yarn install v1.19.0
remote: [1/4] Resolving packages...
remote: [2/4] Fetching packages...
remote: info fsevents@1.2.9: The platform "linux" is incompatible with this module.
remote: info "fsevents@1.2.9" is an optional dependency and failed compatibility check. Excluding it from installation.
remote: [3/4] Linking dependencies...
remote: [4/4] Building fresh packages...
remote: error /tmp/build_8fb6cb960e5fba9ed79ab935cf0403ce/node_modules/node-base64: Command failed.
remote: Exit code: 127
remote: Command: ./install.sh
remote: Arguments:
remote: Directory: /tmp/build_8fb6cb960e5fba9ed79ab935cf0403ce/node_modules/node-base64
remote: Output:
remote: ./install.sh: 3: ./install.sh: node-waf: not found
remote: info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
2条答案
按热度按时间zxlwwiss1#
您应该删除package-lock.json并包含一个yarn.lock,heroku将使用yarn而不是npm进行部署。
6uxekuva2#
我也遇到过类似的问题:一个本地应用程序与reactjs使用Yarn在本地工作,但部署到heroku没有工作。我审查了几个像这样的职位,并尝试了一些教程,没有运气。
我认为,与Heroku是更好地遵循官方文件。我做了什么:我按照这个教程在Heroku中部署了一个简单的React应用程序,然后我把我的代码放在这个应用程序中: