Heroku build failed: heroku-prebuild - heroku

I've recently made updates to a project that I'm trying to deploy on. It was build successfully before, but now running into the following error messages. I'm not sure what the error is as I've already tried to delete package-lock.json, cleared npm cache and reinstall npm. Thanks in advance!
-----> Node.js app detected
-----> Creating runtime environment
NPM_CONFIG_LOGLEVEL=error
NODE_ENV=production
NODE_MODULES_CACHE=true
NODE_VERBOSE=false
-----> Installing binaries
engines.node (package.json): unspecified
engines.npm (package.json): unspecified (use default)
Resolving node version 8.x...
Downloading and installing node 8.12.0...
Using default npm version: 6.4.1
-----> Building dependencies
Running heroku-prebuild
> kickstart#1.0.0 heroku-prebuild /tmp/build_ddb0ffb55870b12204585dc338aab661
> next build
sh: 1: next: not found
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! kickstart#1.0.0 heroku-prebuild: `next build`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the kickstart#1.0.0 heroku-prebuild script.
package.json
{
"name": "kickstart",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"heroku-prebuild": "next build",
"test": "mocha",
"dev": "node server.js",
"start": "next build"
},
"author": "",
"license": "ISC",
"dependencies": {
"fs-extra": "^5.0.0",
"ganache-cli": "^6.1.0",
"mocha": "^4.1.0",
"next": "^4.2.3",
"next-routes": "^1.3.0",
"react": "^16.2.0",
"react-dom": "^16.2.0",
"semantic-ui-css": "^2.3.0",
"semantic-ui-react": "^0.77.2",
"solc": "^0.4.21",
"truffle-hdwallet-provider": "0.0.3",
"web3": "1.0.0-beta.26"
},
"devDependencies": {
"eslint-config-airbnb": "^16.1.0",
"eslint-plugin-import": "^2.9.0",
"eslint-plugin-jsx-a11y": "^6.0.3",
"eslint-plugin-react": "^7.7.0"
}
}

Not 100% sure, but the problem lies in heroku-prebuild where you call next build. At this point, no dependencies are yet installed. You should run next build at a different stage. You already have it as start script.

Related

How do I install laravel jetstream with the official documentation?

I seem to not be able to just make things work with jetstream. I have installed using both livewire and inertia option i keep on getting an error regarding vite when trying to npm build
npm run build
> build
> vite build
failed to load config from **APP_ROOT**\\vite.config.js
error during build:
TypeError: import_laravel_vite_plugin.refreshPaths is not iterable
at Object.<anonymous> (**APP_ROOT**\\vite.config.js:41:39)
at Module._compile (node:internal/modules/cjs/loader:1126:14)
at Object._require.extensions.<computed> [as .js] (file:///F:/PROJECTS/HUGE/CoreRahisify/rahisify-core-gateway-api/node_modules/vite/dist/node/chunks/dep-db16f19c.js:63524:24)
at Module.load (node:internal/modules/cjs/loader:1004:32)
at Function.Module._load (node:internal/modules/cjs/loader:839:12)
at Module.require (node:internal/modules/cjs/loader:1028:19)
at require (node:internal/modules/cjs/helpers:102:18)
at loadConfigFromBundledFile (file:///F:/PROJECTS/HUGE/CoreRahisify/rahisify-core-gateway-api/node_modules/vite/dist/node/chunks/dep-db16f19c.js:63532:21)
at loadConfigFromFile (file:///F:/PROJECTS/HUGE/CoreRahisify/rahisify-core-gateway-api/node_modules/vite/dist/node/chunks/dep-db16f19c.js:63400:34)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
After several attempts now i cant even npm install without errors as i get the following errors:
npm install
npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR!
npm ERR! While resolving: laravel-vite-plugin#0.2.4
npm ERR! Found: vite#3.1.6
npm ERR! node_modules/vite
npm ERR! dev vite#"^3.1.6" from the root project
npm ERR! peer vite#"^3.0.0" from #vitejs/plugin-vue#3.1.2
npm ERR! node_modules/#vitejs/plugin-vue
npm ERR! dev #vitejs/plugin-vue#"^3.0.0" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer vite#"^2.9.9" from laravel-vite-plugin#0.2.4
npm ERR! node_modules/laravel-vite-plugin
npm ERR! dev laravel-vite-plugin#"^0.2.1" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: vite#2.9.15
npm ERR! node_modules/vite
npm ERR! peer vite#"^2.9.9" from laravel-vite-plugin#0.2.4
npm ERR! node_modules/laravel-vite-plugin
npm ERR! dev laravel-vite-plugin#"^0.2.1" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR! See C:\Users\Warren Arnold\AppData\Local\npm-cache\eresolve-report.txt for a full report.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Warren Arnold\AppData\Local\npm-cache\_logs\2022-10-06T19_47_43_871Z-debug-0.log
The following forms my vite.config:
import { defineConfig } from 'vite';
import laravel, { refreshPaths } from 'laravel-vite-plugin';
export default defineConfig({
plugins: [
laravel({
input: [
'resources/css/app.css',
'resources/js/app.js',
],
refresh: [
...refreshPaths,
'app/Http/Livewire/**',
],
}),
],
});
the following is my package.json
{
"private": true,
"scripts": {
"dev": "vite",
"build": "vite build",
"test": "jest",
"jest": "jest --coverage"
},
"devDependencies": {
"#babel/preset-typescript": "^7.18.6",
"#inertiajs/inertia": "^0.11.0",
"#inertiajs/inertia-vue3": "^0.6.0",
"#inertiajs/progress": "^0.2.7",
"#tailwindcss/forms": "^0.5.2",
"#tailwindcss/typography": "^0.5.0",
"#types/express-list-endpoints": "^6.0.0",
"#types/jest": "^29.0.0",
"#vitejs/plugin-vue": "^3.0.0",
"alpinejs": "^3.0.6",
"autoprefixer": "^10.4.7",
"axios": "^0.25",
"date-fns": "^2.28.0",
"express": "^4.18.1",
"laravel-vite-plugin": "^0.2.1",
"lodash": "^4.17.19",
"postcss": "^8.4.14",
"save-dev": "^0.0.1-security",
"tailwindcss": "^3.1.0",
"ts-jest": "^28.0.8",
"ts-node": "^10.9.1",
"typescript": "^4.7.4",
"vite": "^3.1.6",
"vue": "^3.2.31"
},
"dependencies": {
"#babel/preset-env": "^7.18.10",
"#types/express": "^4.17.13",
"#types/morgan": "^1.9.3",
"#types/node-fetch": "^2.6.2",
"babel-jest": "^28.1.3",
"caller-id": "^0.1.0",
"dotenv": "^16.0.2",
"express-list-endpoints": "^6.0.0",
"jest": "^28.1.3",
"morgan": "^1.10.0",
"node-fetch": "^2.6.7",
"nodemon": "^2.0.19",
"nyc": "^15.1.0",
"pg": "^8.8.0",
"sequelize": "^6.21.4"
}
}
I am on node 16.17, laravel 9.19.
The error seems to stem from fact that laravel uses vite 2 while current vite is 3 and yet seems jetstream just installs latest dependencies without considering such. Hence you have to manually try out versions that play well with each other. Currently what worked for me is:
"#vitejs/plugin-vue": "^2.3.3",
"laravel-vite-plugin": "^0.2.1",
"vite": "^2.9.11",
"vue": "^3.2.31"
"tailwindcss": "^3.1.0",
it seems the laravel-vite-plugin are laravel-vite-plugin dependencies are the most conflicting.
To make the changes you can edit the package.json and run npm install or npm install the specific packages specifying the version get installation the link from npm for correct format.
This held me down for quite some hours. Thing is not even about node as above answer as myself was on 16.17, though check on that too, upgrading node ended up in up in more problems about openssl because i had postgres installed too which adds the config in path. I did not want to touch that. After fidgeting around creating separate project and installing breeze separately i caught the error.
I got a hint of whats going on from this tweet from Povilas of Laravel daily after hours of scouring the internet.
This question is similar to mine if am not wrong:
check it out

npm install Fails in one folder but success in other folder of same drive

D:\GDEV1\test\ClientApp\
package.json
.env
...
...
D:\GDEV2\test\ClientApp\ <- Copy of D:\GDEV1\test\ClientApp\ (in the same HDD)
When i npm install at 1) it succeed. but when i npm install at 2) it fails.
(made GDEV3 and GDEV4 but failed at both folder) 1) and 2) are not in the environment
path variable (global npm folder is in the path though)
Package.json ==================================
{
"dependencies": {
"#babel/cli": "^7.15.7",
"#babel/core": "^7.15.8",
"#babel/polyfill": "^7.12.1",
"#babel/preset-env": "^7.15.8",
"axios": "^0.23.0",
"babel-loader": "^8.2.2",
"base64-js": "^1.5.1",
"bignumber": "^1.1.0",
"buffer": "^4.9.2",
"caver-js": "^1.6.4",
"cipher-base": "^1.0.4",
"crypto": "^1.0.1",
"crypto-js": "^4.1.1",
"dotenv": "^10.0.0",
"https-browserify": "^1.0.0",
"init": "^0.1.2",
"qrcode": "^1.4.4",
"stream": "^0.0.2",
"stream-browserify": "^3.0.0",
"web3": "^1.6.1",
"web3-utils": "^1.6.1",
"webpack": "^5.58.2",
"webpack-cli": "^4.9.0",
"webpack-dev-server": "^4.3.1"
},
"scripts": {
"build:GDEV1": "webpack --env build=GDEV1",
"build:GDEV2": "webpack --env build=GDEV2",
"build:LOCAL": "webpack --env build=LOCAL",
"start": "npm run dev -- --open",
"dev": "webpack serve --hot"
},
"devDependencies": {
"css-loader": "^6.4.0",
"html-loader": "^2.1.2",
"style-loader": "^3.3.0"
}
}
error-message ================================
> bufferutil#4.0.5 install D:\Build\BuildGDEV2\22.0804.9c8fc3ce.Web\RpgServer.root\master\WemixWebService\WemixWebService\ClientApp\node_modules\bufferutil
> node-gyp-build
'node-gyp-build'은(는) 내부 또는 외부 명령, 실행할 수 있는 프로그램, 또는 배치 파일이 아닙니다.
npm WARN ClientApp No description
npm WARN ClientApp No repository field.
npm WARN ClientApp No license field.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents#2.3.2 (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents#2.3.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents#1.2.13 (node_modules\watchpack-chokidar2\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents#1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! bufferutil#4.0.5 install: `node-gyp-build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the bufferutil#4.0.5 install 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! C:\Users\abraka\AppData\Roaming\npm-cache\_logs\2022-08-04T07_08_45_736Z-debug.log
it seems that some defendency error occured while installing modules. to node_modules folder when it's in the GDEV2 folder.
But i can't understand why it succeeded everytime in the GDEV1 folder and fails everytime in the GDEV2.
I manually Deleted AppData/Roaming/npm-cache folder and Rebooted and tryed again but the result was same.

Heroku impossible to deploy ENOENT

I have been trying to deploy my app on heroku but i keep getting the same error:
-----> Node.js app detected
-----> Creating runtime environment
NPM_CONFIG_LOGLEVEL=error
NODE_VERBOSE=false
NODE_ENV=production
NODE_MODULES_CACHE=true
-----> Installing binaries
engines.node (package.json): unspecified
engines.npm (package.json): unspecified (use default)
Resolving node version 8.x...
Downloading and installing node 8.11.1...
Using default npm version: 5.6.0
-----> Restoring cache
Skipping cache restore (not-found)
-----> Building dependencies
Prebuild detected (node_modules already exists)
Rebuilding any native modules
npm ERR! path /tmp/build_b970b614b48136e1f3dc8a90ee8f11d9/node_modules/har-validator/bin/har-validator
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall chmod
npm ERR! enoent ENOENT: no such file or directory, chmod '/tmp/build_b970b614b48136e1f3dc8a90ee8f11d9/node_modules/har-validator/bin/har-validator'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! A complete log of this run can be found in:
npm ERR! /tmp/npmcache.wtPoJ/_logs/2018-05-02T14_48_40_930Z-debug.log
-----> Build failed
We're sorry this build is failing! You can troubleshoot common issues here:
https://devcenter.heroku.com/articles/troubleshooting-node-deploys
Some possible problems:
- node_modules checked into source control
https://blog.heroku.com/node-habits-2016#9-only-git-the-important-bits
- Node version not specified in package.json
https://devcenter.heroku.com/articles/nodejs-support#specifying-a-node-js-version
Love,
Heroku
! Push rejected, failed to compile Node.js app.
! Push failed
The app runs fine in localhost if I run npm i then npm start, I have tried to completely rebuild my package.json, I have tried to completely delete the heroku app and recreate one, nothing seems to help.
My package.json looks like this, the most standard possible:
{
"name": "LAD",
"version": "1.0.0",
"description": "xxxxx",
"repository": "git://github.com/xxx/xxx-LAD",
"author": "xxxx",
"license": "xxxxx",
"scripts": {
"start": "node ./bin/www"
},
"dependencies": {
"body-parser": "^1.18.2",
"bootstrap": "^3.3.7",
"compile-sass": "0.0.3",
"connect-ensure-login": "^0.1.1",
"connect-flash": "^0.1.1",
"cookie-parser": "^1.4.3",
"ejs": "^2.5.9",
"express": "^4.16.3",
"express-session": "^1.15.6",
"morgan": "^1.9.0",
"passport": "^0.4.0",
"passport-auth0": "^0.6.1",
"path": "^0.12.7",
"serve-favicon": "^2.5.0"
}
}
Did you try adding node_modules to your .gitignore file and checking in the gitignore file?
I am assuming Heroku is complaining because it's trying to install the node_modules but it already sees a folder called node_modules in the same location.

How to resolve sh: react-scripts: command not found?

I used create-react-app to generate an app.
create-react-app myapp
When I run yarn start or npm start I get this error:
react-scripts start
sh: react-scripts: command not found npm ERR! file sh npm ERR! code
ELIFECYCLE npm ERR! errno ENOENT npm ERR! syscall spawn npm ERR!
myapp#0.1.0 start: react-scripts start npm ERR! spawn ENOENT npm
ERR! npm ERR! Failed at the myapp#0.1.0 start script. npm ERR! This
is probably not a problem with npm. There is likely additional logging
output above.
When I run npm ls react:
myapp#0.1.0 /Users/johnno/foosball
└── react#16.2.0
react-scripts is present.
This is my package.json:
{
"name": "myapp",
"version": "0.1.0",
"private": true,
"dependencies": {
"react": "^16.2.0",
"react-dom": "^16.2.0",
"react-redux": "^5.0.6",
"react-router": "^4.2.0",
"react-scripts": "1.0.17",
"redux": "^3.7.2",
"yarn": "^1.3.2"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
}
}
I tried the suggestions from this but to no avail. How can I fix this issue?
i solved this by deleting
node_modules
yarn.lock
manifest_lock.json
and installed packages by
npm install
or
yarn
Following steps worked for me
delete node_modules folder
delete yarn.lock if you are using yarn command or delete package-lock.json if you are using npm command
run yarn install (for yarn command) or npm install (for npm command)

Error while trying to run npm run build

I have created a simple app with Spring Boot and Angular 4. I tried to run a script which will pack every (npm run build) file from frontend file to the src/main/resources/static file. But I am getting an error which is:
npm ERR! Windows_NT 10.0.15063
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "build"
npm ERR! node v6.9.4
npm ERR! npm v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! tasks#0.0.0 postbuild: `npm run deploy`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the tasks#0.0.0 postbuild script 'npm run deploy'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the tasks package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! npm run deploy
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs tasks
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls tasks
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! C:\Users\Michał\IdeaProjects\spring-angular2-tasks-master\Spring with Angular 4\src\main\frontend\npm-debug.log
My package.json file looks:
{
"name": "tasks",
"version": "0.0.0",
"license": "MIT",
"angular-cli": {},
"scripts": {
"ng": "ng",
"start": "ng serve --proxy-config proxy-conf.json",
"build": "ng build -prod",
"postbuild": "npm run deploy",
"predeploy": "rimraf ../resources/static/ && mkdirp ../resources/static",
"deploy": "copyfiles -f dist/** ../resources/static",
"test": "ng test",
"pree2e": "webdriver-manager update --standalone false --gecko false",
"e2e": "protractor"
},
"private": true,
"dependencies": {
"#angular/common": "^4.1.3",
"#angular/compiler": "^4.1.3",
"#angular/core": "^4.1.3",
"#angular/forms": "^4.1.3",
"#angular/http": "^4.1.3",
"#angular/platform-browser": "^4.1.3",
"#angular/platform-browser-dynamic": "^4.1.3",
"#angular/router": "^4.1.3",
"bootstrap": "^3.3.7",
"copyfiles": "^1.2.0",
"core-js": "^2.4.1",
"mkdirp": "^0.5.1",
"moment": "^2.18.1",
"rimraf": "^2.6.1",
"rxjs": "^5.0.1",
"ts-helpers": "^1.1.1",
"zone.js": "^0.8.11"
},
"devDependencies": {
"#angular/cli": "^1.0.0",
"#angular/compiler-cli": "^4.1.3",
"#types/jasmine": "2.5.47",
"#types/node": "^7.0.22",
"codelyzer": "~3.0.1",
"jasmine-core": "2.6.2",
"jasmine-spec-reporter": "4.1.0",
"karma": "1.7.0",
"karma-chrome-launcher": "^2.0.0",
"karma-cli": "^1.0.1",
"karma-jasmine": "^1.0.2",
"karma-remap-istanbul": "^0.6.0",
"protractor": "~5.1.2",
"ts-node": "3.0.4",
"tslint": "^5.3.2",
"typescript": "~2.3.3"
},
"description": "This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 1.2.6.",
"main": "karma.conf.js",
"author": ""
}
What am I doing wrong?
UPDATE:
After running npm run deploy I have:
> tasks#0.0.0 predeploy C:\Users\Michał\IdeaProjects\spring-angular2-tasks-master\Spring with Angular 4\src\main\frontend
> rimraf ../resources/static/ && mkdirp ../resources/static
> tasks#0.0.0 deploy C:\Users\Michał\IdeaProjects\spring-angular2-tasks-master\Spring with Angular 4\src\main\frontend
> copyfiles -f dist/** ../resources/static
'copyfiles' is not recognized as an internal or external command,
operable program or batch file.
npm ERR! Windows_NT 10.0.15063
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "deploy"
npm ERR! node v6.9.4
npm ERR! npm v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! tasks#0.0.0 deploy: `copyfiles -f dist/** ../resources/static`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the tasks#0.0.0 deploy script 'copyfiles -f dist/** ../resources/static'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the tasks package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! copyfiles -f dist/** ../resources/static
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs tasks
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls tasks
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! C:\Users\Michał\IdeaProjects\spring-angular2-tasks-master\Spring with Angular 4\src\main\frontend\npm-debug.log
Solve it by npm install copyfiles -g

Resources