#node.js #heroku #build #package.json
#node.js #heroku #сборка #package.json
Вопрос:
Я реорганизовал свое приложение, и когда я пришел, чтобы перестроить его на свой сервер heroku, я получил следующую ошибку
remote: ! ERROR: Application not supported by 'heroku/nodejs' buildpack remote: ! remote: ! The 'heroku/nodejs' buildpack is set on this application, but was remote: ! unable to detect a Node.js codebase.
Я понимаю, что эту проблему можно решить, изменив структуру моих папок. Я не хочу этого делать, потому что это хорошо организовано как есть. Я хочу выяснить, как решить проблему без реструктуризации моего проекта.
текущая структура папок
clientpackage.json
clientnode_modules
client{all other client files}
serverpackage.json
server{all other server files}
servernone_modules
wiki{all wiki files}
.gitignore
ТО, ЧТО Я ПРОБОВАЛ
Я читал статьи, предлагающие поместить package.json в корневой каталог. Я пробовал использовать пустой файл json с именем package.json, но он не сработал, так как я предполагаю, что он на самом деле использует файл и хочет прочитать тот, который находится в моем каталоге server, для запуска сценариев сборки.
Мне было интересно, могу ли я просто вызвать heruku для запуска в другом каталоге?
ПОПЫТКА 2
Я попытался создать файл с именем Procfile и добавил в него следующее содержимое
web: npm client
server: npm start
когда я затем создал коммит и запустил
git push heroku master
Я получил следующую ошибку
emote: ! ERROR: Application not supported by 'heroku/nodejs' buildpack
remote: !
remote: ! The 'heroku/nodejs' buildpack is set on this application, but was
remote: ! unable to detect a Node.js codebase.
remote: !
remote: ! A Node.js app on Heroku requires a 'package.json' at the root of
remote: ! the directory structure.
remote: !
remote: ! If you are trying to deploy a Node.js application, ensure that this
remote: ! file is present at the top level directory. This directory has the
remote: ! following files:
remote: !
remote: ! client/
remote: ! readme.md
remote: ! server/
remote: ! services/
remote: ! wiki/
remote: !
remote: ! If you are trying to deploy an application written in another
remote: ! language, you need to change the list of buildpacks set on your
remote: ! Heroku app using the 'heroku buildpacks' command.
remote: !
remote: ! For more information, refer to the following documentation:
remote: ! https://devcenter.heroku.com/articles/buildpacks
remote: ! https://devcenter.heroku.com/articles/nodejs-support#activation
remote:
remote:
remote: More info: https://devcenter.heroku.com/articles/buildpacks#detection-failure
remote:
remote: ! Push failed
remote: Verifying deploy...
remote:
remote: ! Push rejected to infinite-refuge-86248.
remote:
To https://git.heroku.com/infinite-refuge-86248.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/infinite-refuge-86248.git'
Для справки ниже приведен мой серверный файл JSON
{
"name": "Infoshot",
"version": "0.0.4",
"description": "Research Tool",
"main": "server.js",
"scripts": {
"start": "node server.js",
"server": "nodemon server.js",
"client": "npm start --prefix ../client/",
"clientinstall": "npm install --prefix client",
"dev": "concurrently "npm run server" "npm run client"",
"heroku-postbuild": "NPM_CONFIG_PRODUCTION=false npm install --prefix client amp;amp; npm run build --prefix client "
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"bcryptjs": "^2.4.3",
"config": "^3.2.2",
"dotenv": "^8.2.0",
"enzyme": "^3.11.0",
"express": "^4.17.1",
"express-validator": "^6.2.0",
"jsonwebtoken": "^8.5.1",
"mongoose": "^5.7.0",
"nodemailer": "^6.4.14",
"nodemailer-sendgrid": "^1.0.3"
},
"devDependencies": {
"concurrently": "^4.1.2",
"nodemon": "^1.19.2"
}
}
Ответ №1:
Попробуйте добавить Procfile
в свой корневой каталог что-то вроде приведенного ниже:
web: npm client
server: npm start
Комментарии:
1. Я создал файл, который вы описали выше, и поместил его в свой корень, и получил эту ошибку при попытке развертывания в heruku
2. удаленный: ——> Приложение, несовместимое со buildpack: buildpack-registry.s3.amazonaws.com/buildpacks/heroku /… пульт дистанционного управления: пульт дистанционного управления: ! ОШИБКА: приложение не поддерживается пакетом сборки heroku / nodejs
3. Я обновлю вопрос с полной ошибкой и именно тем, что я сделал
4. подробнее см. Попытку 2 в документе