Heroku NodeJS App Build Failing - javascript

I'm receiving a build failed error while deploying my NodeJS app to Heroku. Here is the build log:
-----> 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): 8.10.0
engines.npm (package.json): 5.7.1
Resolving node version 8.10.0...
Downloading and installing node 8.10.0...
Bootstrapping npm 5.7.1 (replacing 5.6.0)...
npm 5.7.1 installed
-----> Restoring cache
Loading 2 from cacheDirectories (default):
- node_modules
- bower_components (not cached - skipping)
-----> Building dependencies
Installing node modules (package.json + package-lock)
npm ERR! path /tmp/build_39ba38c4a10780e26942fa5ee7294cd5/node_modules/fsevents/node_modules/abbrev
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall rename
npm ERR! enoent ENOENT: no such file or directory, rename '/tmp/build_39ba38c4a10780e26942fa5ee7294cd5/node_modules/fsevents/node_modules/abbrev'
-> '/tmp/build_39ba38c4a10780e26942fa5ee7294cd5/node_modules/fsevents/node_modules/.abbrev.DELETE'
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.X6IAU/_logs/2018-03-24T03_18_22_202Z-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
If you're stuck, please submit a ticket so we can help:
https://help.heroku.com/
Love,
Heroku
! Push rejected, failed to compile Node.js app. ! Push failed
I have deleted my node_modules folder and ran npm install and deleted/installed the abbrev npm package. Still the same error after this.
Here is my package.json:
{
"name": "test",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"dev": "nodemon bin/dev",
"clean": "rm -rf dist",
"build": "npm run clean && mkdir dist && babel server -s -d dist",
"production": "npm run build && nodemon bin/production"
},
"keywords": [],
"author": "",
"devDependencies": {
"dotenv": "^4.0.0"
},
"dependencies": {
"async": "^2.6.0",
"babel-cli": "^6.26.0",
"babel-polyfill": "^6.26.0",
"babel-preset-env": "^1.6.1",
"bcrypt-nodejs": "0.0.3",
"body-parser": "^1.18.2",
"boom": "^7.2.0",
"compression": "^1.7.2",
"cron": "^1.3.0",
"express": "^4.16.3",
"express-rate-limit": "^2.11.0",
"express-validator": "^3.2.1",
"flat": "^4.0.0",
"generate-password": "^1.4.0",
"helmet": "^3.12.0",
"jsonwebtoken": "^7.4.3",
"moment": "^2.21.0",
"moment-timezone": "^0.5.14",
"mongoose": "^4.13.12",
"morgan": "^1.9.0",
"nodemon": "^1.17.2",
"passport": "^0.3.2",
"passport-jwt": "^2.2.1",
"passport-local": "^1.0.0",
"sendgrid": "^5.2.3",
"twilio": "^3.13.1",
"uuid": "^3.2.1"
},
"engines": {
"node": "8.10.0",
"npm": "5.7.1"
}
}
Any suggestions are appreciated. Thank you.

Related

heoku is not finding ws (websocket)

I have an App that locally works.
$env:ENV="local"
npm run dev
Its Package.json
{
"name": "forge-dataviz-iot-reference-app",
"version": "0.3.3",
"description": "Autodesk Forge Viewer Data Visualization Sample Application",
"main": "server/localserver.js",
"engines": {
"node": "14.19.2"
},
"scripts": {
"postinstall": "cd server && npm install",
"dev": "concurrently --kill-others \"npm run watch\" \"npm run start\" \"nodemon server/localserver.js --delay 300ms --ext js,jsx\"",
"start": "ws -p 9081",
"watch": "webpack --watch --config webpack.config.js",
"dev-client": "npm install && concurrently --kill-others \"npm run watch\" \"npm run start\"",
"build": "webpack --config webpack.config.js"
},
"repository": {
"type": "git",
"url": "https://github.com/Autodesk-Forge/forge-dataviz-iot-reference-app.git"
},
"author": "Autodesk Inc.",
"license": "MIT",
"devDependencies": {
"#babel/core": "^7.0.0-beta.41",
"#babel/plugin-transform-spread": "^7.13.0",
"#babel/preset-env": "7.12.11",
"#babel/preset-react": "7.12.13",
"babel-loader": "^8.1.0",
"concurrently": "^3.5.1",
"css-loader": "3.6.0",
"local-web-server": "4.2.1",
"mini-css-extract-plugin": "^1.4.0",
"node-loader": "^1.0.2",
"node-sass": "^5.0.0",
"nodemon": "2.0.7",
"react": "16.13.1",
"react-dom": "16.13.1",
"sass-loader": "^10.1.1",
"svg-url-loader": "^7.1.1",
"webpack": "^5.11.0",
"webpack-cli": "^4.5.0",
"webpack-node-externals": "^1.7.2"
},
"dependencies": {
"#hig/theme-data": "^2.17.0",
"#material-ui/core": "^4.11.0",
"#material-ui/icons": "^4.9.1",
"#material-ui/lab": "^4.0.0-alpha.56",
"chronos-etu": "3.1.0",
"codemirror": "^5.61.1",
"echarts": "^4.9.0",
"echarts-for-react": "^2.0.16",
"forge-dataviz-iot-data-modules": "0.1.11",
"forge-dataviz-iot-react-components": "0.1.17",
"lodash": "^4.17.15",
"moment": "^2.27.0",
"pixi.js": "^5.3.7",
"q": "^1.5.1",
"react-codemirror2": "^7.2.1",
"react-copy-to-clipboard": "^5.0.3",
"react-dates": "^21.8.0",
"react-rnd": "^10.2.1",
"react-router-dom": "5.2.0",
"socket.io": "^3.0.4",
"socket.io-client": "^3.0.4",
"ws": "^6.2.2",
"uuid": "^8.3.2"
}
}
Procfile // IS IT OK???
$env:ENV="local"
web: npm run dev
Error
heroku logs --tail
2022-06-01T05:23:27.918673+00:00 app[web.1]: > forge-dataviz-iot-reference-app#0.3.3 start /app
2022-06-01T05:23:27.918673+00:00 app[web.1]: > ws -p 9081
2022-06-01T05:23:27.918674+00:00 app[web.1]:
2022-06-01T05:23:27.929836+00:00 app[web.1]: sh: 1: ws: not found
2022-06-01T05:23:27.935528+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2022-06-01T05:23:27.935911+00:00 app[web.1]: npm ERR! syscall spawn
2022-06-01T05:23:27.936120+00:00 app[web.1]: npm ERR! file sh
2022-06-01T05:23:27.936316+00:00 app[web.1]: npm ERR! errno ENOENT
2022-06-01T05:23:27.945101+00:00 app[web.1]: npm ERR! forge-dataviz-iot-reference-app#0.3.3 start: `ws -p 9081`
2022-06-01T05:23:27.945232+00:00 app[web.1]: npm ERR! spawn ENOENT
2022-06-01T05:23:27.945381+00:00 app[web.1]: npm ERR!
2022-06-01T05:23:27.945506+00:00 app[web.1]: npm ERR! Failed at the forge-dataviz-iot-reference-app#0.3.3 start script.
2022-06-01T05:23:27.945622+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
Someone please download app (if required) from link to findout this problem.
I tried:
1: npm install --save ws
2: npm install --save ws#6.2.2
3:put it in package.json // originally it was not there.
4:delete node modules and installed again
5: delete app and made new one
But the error is still there. How can I make it work on Heroku?

can't install dependencies because of node and webpack version conflict

I am trying to install the dependencies with the exact version which are listed in json file, and I got errors below:
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! Found: webpack#4.46.0
npm ERR! node_modules/webpack
npm ERR! webpack#"^4.35.3" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer webpack#"^5.1.0" from terser-webpack-plugin#5.3.1
npm ERR! node_modules/terser-webpack-plugin
npm ERR! dev terser-webpack-plugin#"^5.1.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.
since the dependencies with the required version are not the latest one, I downgrade my node.js from latest version 16 to 14+, and install with npm i --leacy-peer-deps, but the error shows still the same, seems the version from node or webpack still not compatible to the dependencies(Found: webpack#4.46.0
npm ERR! node_modules/webpack
npm ERR! webpack#"^4.35.3" from the root project).
how can I solve this problem?
here is the json list:
{
"name": "example-project",
"version": "1.0.0",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node src/server/index.js",
"build-prod": "webpack --config webpack.prod.js",
"build-dev": "webpack-dev-server --config webpack.dev.js --open"
},
"keywords": [],
"author": "",
"license": "ISC",
"description": "",
"dependencies": {
"dotenv": "^8.2.0",
"express": "^4.17.1",
"jest-fetch-mock": "^3.0.3",
"webpack": "^4.35.3",
"webpack-cli": "^3.3.5"
},
"devDependencies": {
"#babel/core": "^7.13.15",
"#babel/plugin-transform-modules-commonjs": "^7.13.8",
"#babel/preset-env": "^7.13.15",
"babel-loader": "^8.2.2",
"body-parser": "^1.19.0",
"clean-webpack-plugin": "^3.0.0",
"cors": "^2.8.5",
"css-loader": "^5.2.1",
"html-webpack-plugin": "^3.2.0",
"jest": "^26.6.3",
"mini-css-extract-plugin": "^1.4.1",
"node-fetch": "^2.6.1",
"node-sass": "^5.0.0",
"optimize-css-assets-webpack-plugin": "^5.0.4",
"sass": "^1.32.8",
"sass-loader": "^10.1.1",
"style-loader": "^2.0.0",
"terser-webpack-plugin": "^5.1.1",
"webpack-dev-server": "^3.11.2",
"workbox-webpack-plugin": "^6.1.5"
}
}
Try to delete package-lock.json and clear npm cache using 'npm cache clean -f' before npm i.
Caret (^) notation: It will update you to all future minor/patch versions, without incrementing the major version. ^2.3.4 will use releases from 2.3.4 to <3.0.0
Tilde ( ~ ): It will update you to all future patch versions, without incrementing the minor version. ~1.2.3 will use releases from 1.2.3 to <1.3.

heroku deploy not working when local build works fine - NodeJS Timeout

Title says it really - i can build locally but it fails to deploy. Has an issue with Timeout - not sure how to force this to work?
Here's my package.json, and the logs afterwards.
I tried adding Timeout by running a yarn install but then it triggered some other dependency issues with node-gyp
Many thanks for any tips!
Package.json
{
"name": "api",
"homepage": ".",
"version": "0.0.1",
"private": true,
"scripts": {
"lint": "eslint .",
"dev": "NODE_ENV=development nodemon --watch '**/*' -e ts,tsx,js --ignore 'src/**/*.spec.ts' --exec 'ts-node --project ./tsconfig.json' src/server.ts",
"start": "node ./dist/server.js",
"start:redis": "docker-compose up -d",
"build": "NODE_ENV=production tsc"
},
"engines":{
"node":"14.15.5",
"npm": "6.14.11",
"yarn": "1.22.15"
},
"license": "MIT",
"main": "dist/server.js",
"devDependencies": {
"#types/cookie": "^0.4.0",
"#types/puppeteer": "^5.4.4",
"#types/ramda": "^0.27.44",
"#types/redis": "^2.8.31",
"#types/user-agents": "^1.0.2",
"#typescript-eslint/eslint-plugin": "^4.19.0",
"#typescript-eslint/parser": "^4.19.0",
"eslint": "^7.22.0",
"eslint-config-prettier": "^8.1.0",
"nodemon": "^2.0.12",
"prettier": "~2.2.1",
"tslib": "^2.0.0",
"typescript": "^4.0.0"
},
"dependencies": {
"axios": "^0.21.1",
"body-parser": "^1.19.0",
"chalk": "^4.1.2",
"cookie": "^0.4.1",
"cookie-parser": "^1.4.5",
"cors": "^2.8.5",
"dotenv": "^10.0.0",
"express": "^4.17.1",
"express-async-router": "^0.1.15",
"express-query-boolean": "^2.0.0",
"node-fetch": "^2.6.1",
"puppeteer": "^10.2.0",
"puppeteer-extra": "^3.1.18",
"puppeteer-extra-plugin-adblocker": "^2.11.11",
"puppeteer-extra-plugin-stealth": "^2.7.8",
"ramda": "^0.27.1",
"redis": "^3.1.2",
"user-agents": "^1.0.738",
"util": "^0.12.4"
}
}
Build logs
>
-----> Building on the Heroku-20 stack
-----> Using buildpack: heroku/nodejs
-----> 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): 14.15.5
engines.npm (package.json): 6.14.11
engines.yarn (package.json): 1.22.15
Resolving node version 14.15.5...
Downloading and installing node 14.15.5...
npm 6.14.11 already installed with node
Resolving yarn version 1.22.15...
Downloading and installing yarn (1.22.15)
Installed yarn 1.22.15
-----> Restoring cache
Cached directories were not restored due to a change in version of node, npm, yarn or stack
Module installation may take longer for this build
-----> Installing dependencies
Installing node modules (package.json)
> puppeteer#10.4.0 install /tmp/build_e4061cb3/node_modules/puppeteer
> node install.js
> nodemon#2.0.13 postinstall /tmp/build_e4061cb3/node_modules/nodemon
> node bin/postinstall || exit 0
Love nodemon? You can now support the project via the open collective:
> https://opencollective.com/nodemon/donate
added 477 packages from 392 contributors and audited 479 packages in 31.801s
76 packages are looking for funding
run `npm fund` for details
found 0 vulnerabilities
-----> Build
Running build
> api#0.0.1 build /tmp/build_e4061cb3
> NODE_ENV=production tsc
node_modules/puppeteer/lib/types.d.ts(3644,28): error TS2694: Namespace 'NodeJS' has no exported member 'Timeout'.
node_modules/puppeteer/lib/types.d.ts(6489,71): error TS2583: Cannot find name 'BigInt'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2020' or later.
node_modules/puppeteer/lib/types.d.ts(6894,28): error TS2694: Namespace 'NodeJS' has no exported member 'Timeout'.
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! api#0.0.1 build: `NODE_ENV=production tsc`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the api#0.0.1 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.LPsTK/_logs/2021-10-13T12_15_23_280Z-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
If you're stuck, please submit a ticket so we can help:
https://help.heroku.com/
Love,
Heroku
! Push rejected, failed to compile Node.js app.
! Push failed
The problem seems to be missing types, here are two possible fix:
Install #types/node as a devDependencies. This package contains types for NodeJS, including the Timeout type.
Edit your tsconfig.json to set skipLibCheck to true:
{
"compilerOptions": {
"skipLibCheck": true
}
}
This will ignore type errors in d.ts files (your error come from node_modules/puppeteer/lib/types.d.ts so it should fix it).

Chunk.entrypoints: Use Chunks.addGroup instead

I'm using npm version 6.0.1.
my os is macOs High Sierra Version 10.13.3
I want to build my project but I got this error message:
Creating an optimized production build...
/Users/mohammadmehdi/Documents/Work/sevenapp/node_modules/webpack/lib/Chunk.js:533
throw new Error("Chunk.entrypoints: Use Chunks.addGroup instead");
^
Error: Chunk.entrypoints: Use Chunks.addGroup instead
at Chunk.set (/Users/mohammadmehdi/Documents/Work/sevenapp/node_modules/webpack/lib/Chunk.js:533:9)
at /Users/mohammadmehdi/Documents/Work/sevenapp/node_modules/extract-text-webpack-plugin/dist/index.js:176:40
at Array.forEach (<anonymous>)
at Compilation.<anonymous> (/Users/mohammadmehdi/Documents/Work/sevenapp/node_modules/extract-text-webpack-plugin/dist/index.js:171:18)
at Compilation.applyPluginsAsyncSeries (/Users/mohammadmehdi/Documents/Work/sevenapp/node_modules/react-scripts/node_modules/tapable/lib/Tapable.js:206:13)
at Compilation.seal (/Users/mohammadmehdi/Documents/Work/sevenapp/node_modules/react-scripts/node_modules/webpack/lib/Compilation.js:605:8)
at applyPluginsParallel.err (/Users/mohammadmehdi/Documents/Work/sevenapp/node_modules/react-scripts/node_modules/webpack/lib/Compiler.js:508:17)
at /Users/mohammadmehdi/Documents/Work/sevenapp/node_modules/react-scripts/node_modules/tapable/lib/Tapable.js:289:11
at _addModuleChain (/Users/mohammadmehdi/Documents/Work/sevenapp/node_modules/react-scripts/node_modules/webpack/lib/Compilation.js:507:11)
at processModuleDependencies.err (/Users/mohammadmehdi/Documents/Work/sevenapp/node_modules/react-scripts/node_modules/webpack/lib/Compilation.js:477:14)
at process._tickCallback (internal/process/next_tick.js:172:11)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! sevenapp#0.1.0 build: `react-scripts build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the sevenapp#0.1.0 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! /Users/mohammadmehdi/.npm/_logs/2018-07-02T13_17_58_331Z-debug.log
this is my package.json:
{
"name": "sevenapp",
"version": "0.1.0",
"private": true,
"dependencies": {
"axios": "^0.18.0",
"bootstrap": "^4.0.0",
"jquery": "^3.3.1",
"rc-pagination": "^1.16.4",
"react": "^16.2.0",
"react-countup": "^3.0.3",
"react-dom": "^16.2.0",
"react-paginate": "^5.2.3",
"react-player": "^1.6.4",
"react-popup": "^0.9.3",
"react-redux": "^5.0.7",
"react-router": "^4.2.0",
"react-router-dom": "^4.2.2",
"react-scripts": "1.1.1",
"redux": "^4.0.0"
},
"scripts": {
"start": "PORT=3000 react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
},
"description": "",
"main": "index.js",
"devDependencies": {
"babel-core": "^6.26.0",
"babel-loader": "^7.1.4",
"css-loader": "^0.28.11",
"jshint": "^2.9.5",
"jshint-loader": "^0.8.4",
"style-loader": "^0.21.0",
"webpack": "^4.6.0",
"webpack-cli": "^2.0.15"
},
"author": "",
"license": "ISC"
}
I run this command:
npm run build --release
Do I need to install webpack?
Can I build my project without webpack?
I want to release my project?
I don't know what is my wrong.
Looks related to webpack-contrib/extract-text-webpack-plugin#701.
Running npm install -D extract-text-webpack-plugin#next solved the issue locally for me.
you can also check same thread here on below link https://github.com/facebook/create-react-app/issues/4356

Error with watchify when trying to execute npm run watch

Good day, i'm currently doing a tutorial on scotch.io where i'm trying to make a music player using electron and react, but when i try to execute 'npm run watch' i get this error message:
electron-quick-start#1.0.0 watch: watchify app/app.js -t babelify -o public/js/bundle.js --debug --verbose
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the electron-quick-start#1.0.0 watch script 'watchify app/app.js -t babelify -o public/js/bundle.js --debug --verbose'.
npm ERR! This is most likely a problem with the electron-quick-start package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! watchify app/app.js -t babelify -o public/js/bundle.js --debug --verbose
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs electron-quick-start
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!
npm ERR! npm owner ls electron-quick-start
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! C:\Users\Alejandro\Documents\Proyectos\music-player\npm-debug.log
This is my package.json
{
"name": "electron-quick-start",
"version": "1.0.0",
"description": "A minimal Electron application",
"main": "main.js",
"scripts": {
"start": "electron .",
"watch": "watchify app/app.js -t babelify -o public/js/bundle.js --debug --verbose"
},
"repository": {
"type": "git",
"url": "git+https://github.com/electron/electron-quick-start.git"
},
"keywords": [
"Electron",
"quick",
"start",
"tutorial"
],
"author": "GitHub",
"license": "CC0-1.0",
"bugs": {
"url": "https://github.com/electron/electron-quick-start/issues"
},
"homepage": "https://github.com/electron/electron-quick-start#readme",
"devDependencies": {
"babelify": "^7.3.0",
"browserify": "^13.0.1",
"electron-prebuilt": "^1.2.0"
},
"dependencies": {
"axios": "^0.13.1",
"babel": "^6.5.2",
"babel-core": "^6.10.4",
"babel-preset-es2015": "^6.9.0",
"babel-preset-react": "^6.11.1",
"babelify": "^7.3.0",
"browserify": "^13.0.1",
"classnames": "^2.2.5",
"electron-prebuilt": "^1.2.7",
"electron-reload": "^1.0.0",
"jquery": "^3.1.0",
"react": "^15.2.1",
"react-autocomplete": "^1.0.1",
"react-dom": "^15.2.1",
"react-sound": "^0.5.0",
"soundmanager2": "^2.97.20150601-a"
}
}
From what i've read in the tutorial browserify is supposed to come with watchify as well, however when i installed it as a separate module it worked but then i got the following error:
console.error("SyntaxError: C:/Users/Alejandro/Documents/Proyectos/music-player/app/app.js: Unexpected token (12:10) while parsing file: C:\Users\Alejandro\Documents\Proyectos\music-player\app\app.js");
I used the same tutorial, but I could not get everything working by applying the code snippets from the tutorial.
Do this instead:
install both browserify and watchify:
npm install -g browserify watchify
clone the author's music player github repository instead of electron-quick-start. Then add or modify the tutorial code snippets.

Categories