node-gyp-build not found when Deploying web3 App to heroku - node.js

I'm attempting to deploy a web3 application to heroku, but while building the npm dependencies, I get the following error:
remote: sh: 1: node-gyp-build: not found
remote: npm ERR! code ELIFECYCLE
remote: npm ERR! syscall spawn
remote: npm ERR! file sh
remote: npm ERR! errno ENOENT
remote: npm ERR! bufferutil#4.0.3 install: `node-gyp-build`
remote: npm ERR! spawn ENOENT
remote: npm ERR!
remote: npm ERR! Failed at the bufferutil#4.0.3 install script.
I believe this is because of the web3#1.3.6 dependency I am adding. If I leave this out of the npm dependencies in my package.json file, the deploy works successfully.
If I ssh into a console, I'm able to run npm install -g web3#1.3.6 and that is also successful. I've also tried adding node-gyp, node-gyp-build, and bufferutil as explicit dependencies in the package.json file. I'm using
node 14.17.0
npm 6.14.13
python 3.9.5
Below is my full package.json file
{
"engines": {
"node": "14.17.0",
"npm": "6.14.13"
},
"repository": {},
"description": " ",
"license": "MIT",
"scripts": {
"deploy": "webpack --mode production",
"watch": "webpack --mode development --watch"
},
"dependencies": {
"postcss": "8.1.0",
"#popperjs/core": "^2.9.2",
"bootstrap": "^5.0.1",
"jquery": "^3.6.0",
"phoenix": "file:../deps/phoenix",
"phoenix_html": "file:../deps/phoenix_html",
"phoenix_live_view": "file:../deps/phoenix_live_view",
"topbar": "^0.1.4",
"#babel/core": "^7.0.0",
"babel-polyfill": "^6.26.0",
"#babel/preset-env": "^7.0.0",
"babel-loader": "^8.0.0",
"css-loader": "^5.2.6",
"sass-loader": "^10.0.0",
"node-sass": "^6.0.0",
"cropperjs": "1.5.12",
"eth-sig-util": "^1.4.2",
"jquery-cropper": "1.0.1",
"copy-webpack-plugin": "^5.1.1",
"hard-source-webpack-plugin": "^0.13.1",
"mini-css-extract-plugin": "^0.9.0",
"optimize-css-assets-webpack-plugin": "^5.0.1",
"terser-webpack-plugin": "^2.3.2",
"webpack": "^4.41.5",
"webpack-cli": "^3.3.2",
"web3": "1.3.6"
},
"devDependencies": {},
}

Related

Why i receive error message while install typeorm?

I tried to build my project with Jenkins.
Node version: 16.16.0
Npm version: 8.11.0
Env: Ubuntu 20.04.4 LTS
Jenkins pulled git repo and tried to install dependencies.
I installed nodejs plugin to jenkins.
If i tried run npm i manually from /var/lib/jenkins/workspace it shows me same error log.
npm i working correctly on my local machine (Windows 10)
Also i tried to re-install node and npm with versions from my local machine, but nothing happened :(
My error log:
00:07:51 npm ERR! code ERESOLVE
00:07:51 npm ERR! ERESOLVE could not resolve
00:07:51 npm ERR!
00:07:51 npm ERR! While resolving: #nestjs/typeorm#8.0.3
00:07:51 npm ERR! Found: typeorm#0.3.6
00:07:51 npm ERR! node_modules/typeorm
00:07:51 npm ERR! typeorm#"^0.3.6" from the root project
00:07:51 npm ERR!
00:07:51 npm ERR! Could not resolve dependency:
00:07:51 npm ERR! peer typeorm#"^0.2.34" from #nestjs/typeorm#8.0.3
00:07:51 npm ERR! node_modules/#nestjs/typeorm
00:07:51 npm ERR! #nestjs/typeorm#"^8.0.3" from the root project
00:07:51 npm ERR!
00:07:51 npm ERR! Conflicting peer dependency: typeorm#0.2.45
00:07:51 npm ERR! node_modules/typeorm
00:07:51 npm ERR! peer typeorm#"^0.2.34" from #nestjs/typeorm#8.0.3
00:07:51 npm ERR! node_modules/#nestjs/typeorm
00:07:51 npm ERR! #nestjs/typeorm#"^8.0.3" from the root project
00:07:51 npm ERR!
00:07:51 npm ERR! Fix the upstream dependency conflict, or retry
00:07:51 npm ERR! this command with --force, or --legacy-peer-deps
00:07:51 npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
00:07:51 npm ERR!
00:07:51 npm ERR! See /var/lib/jenkins/.npm/eresolve-report.txt for a full report.
00:07:51
00:07:51 npm ERR! A complete log of this run can be found in:
00:07:51 npm ERR! /var/lib/jenkins/.npm/_logs/2022-07-20T21_07_43_903Z-debug-0.log
package.json file:
{
"name": "teach-me-grow",
"version": "0.0.1",
"description": "",
"author": "",
"private": true,
"license": "UNLICENSED",
"scripts": {
"prebuild": "rimraf dist",
"build": "nest build",
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
"start": "nest start",
"start:dev": "nest start --watch",
"start:debug": "nest start --debug --watch",
"start:prod": "node dist/main",
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
"test": "jest",
"test:watch": "jest --watch",
"test:cov": "jest --coverage",
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
"test:e2e": "jest --config ./test/jest-e2e.json"
},
"dependencies": {
"#nestjs/common": "^8.0.0",
"#nestjs/core": "^8.0.0",
"#nestjs/passport": "^8.2.1",
"#nestjs/platform-express": "^8.0.0",
"#nestjs/swagger": "^5.2.1",
"#nestjs/typeorm": "^8.0.3",
"class-validator": "^0.13.2",
"connect-typeorm": "^1.1.4",
"dotenv": "^16.0.1",
"express-session": "^1.17.3",
"module-alias": "^2.2.2",
"passport": "^0.5.3",
"passport-facebook": "^3.0.0",
"passport-google-oauth20": "^2.0.0",
"passport-local": "^1.0.0",
"pg": "^8.7.3",
"pg-hstore": "^2.3.4",
"reflect-metadata": "^0.1.13",
"rimraf": "^3.0.2",
"rxjs": "^7.2.0",
"swagger-ui-express": "^4.4.0",
"typeorm": "^0.3.6"
},
"devDependencies": {
"#nestjs/cli": "^8.0.0",
"#nestjs/schematics": "^8.0.0",
"#nestjs/testing": "^8.0.0",
"#types/express": "^4.17.13",
"#types/jest": "27.5.0",
"#types/node": "^16.0.0",
"#types/supertest": "^2.0.11",
"#typescript-eslint/eslint-plugin": "^5.0.0",
"#typescript-eslint/parser": "^5.0.0",
"eslint": "^8.0.1",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-prettier": "^4.0.0",
"jest": "28.0.3",
"prettier": "^2.3.2",
"source-map-support": "^0.5.20",
"supertest": "^6.1.3",
"ts-jest": "28.0.1",
"ts-loader": "^9.2.3",
"ts-node": "^10.0.0",
"tsconfig-paths": "4.0.0",
"typescript": "^4.3.5"
},
"jest": {
"moduleFileExtensions": [
"js",
"json",
"ts"
],
"rootDir": "src",
"testRegex": ".*\\.spec\\.ts$",
"transform": {
"^.+\\.(t|j)s$": "ts-jest"
},
"collectCoverageFrom": [
"**/*.(t|j)s"
],
"coverageDirectory": "../coverage",
"testEnvironment": "node"
},
"_moduleAliases": {
"#app": "./dist"
}
}
Looking on nestjs/typeorm in version 8.0.3 it has fixed version of typeorm package in its dependencies (package.json: https://github.com/nestjs/typeorm/blob/8.0.3/package.json)
If you want to stick to nestjs/typeorm 8.0.3 version lower your typeorm version to 0.2.45 or upgrade nestjs/typeorm version to one which uses newer typeorm version

docker build vue3 not compatible with element-ui on node:16-buster-slim

dockerfile:
FROM node:16-buster-slim
RUN apt-get update
WORKDIR /app
COPY package.json /home
RUN npm install --prefix /home
package.json
{
"name": "test",
"version": "0.1.0",
"private": false,
"scripts": {
"dev": "vue-cli-service serve --mode development --host 0.0.0.0",
"serve": "vue-cli-service serve --mode production --host 0.0.0.0",
"build": "vue-cli-service build",
"jest": "vue-cli-service test:unit --watchAll",
"lint": "vue-cli-service lint"
},
"dependencies": {
"axios": "^0.21.4",
"core-js": "^3.6.5",
"dateformat": "^5.0.2",
"element-plus": "^1.1.0-beta.9",
"element-ui": "^2.15.6",
"lib-flexible": "^0.3.2",
"ol": "^6.6.1",
"spark-md5": "^3.0.2",
"vue": "^3.0.0",
"vue-router": "^4.0.0-0",
"vuelayers": "^0.11.36",
"vuex": "^4.0.0-0"
},
"devDependencies": {
"#vue/cli-plugin-babel": "~4.5.0",
"#vue/cli-plugin-eslint": "~4.5.0",
"#vue/cli-plugin-router": "~4.5.0",
"#vue/cli-plugin-unit-jest": "~4.5.0",
"#vue/cli-plugin-vuex": "~4.5.0",
"#vue/cli-service": "~4.5.0",
"#vue/compiler-sfc": "^3.0.0",
"#vue/eslint-config-standard": "^5.1.2",
"#vue/test-utils": "^2.0.0-0",
"babel-eslint": "^10.1.0",
"babel-plugin-component": "^1.1.1",
"eslint": "^6.7.2",
"eslint-plugin-import": "^2.20.2",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-promise": "^4.2.1",
"eslint-plugin-standard": "^4.0.0",
"eslint-plugin-vue": "^7.0.0",
"fs-extra": "^10.0.0",
"lint-staged": "^9.5.0",
"mockjs": "^1.1.0",
"node-sass": "^4.14.1",
"px2rem-loader": "^0.1.9",
"sass-loader": "^8.0.2",
"typescript": "~3.9.3",
"vue-jest": "^5.0.0-0"
},
"gitHooks": {
"pre-commit": "lint-staged"
},
"lint-staged": {
"*.{js,jsx,vue}": [
"vue-cli-service lint",
"git add"
]
}
}
Step: RUN npm install --prefix /home
---> Running in fc08d7e933ed npm notice
npm notice New patch version of npm available! 8.1.0 -> 8.1.4
npm notice Changelog: https://github.com/npm/cli/releases/tag/v8.1.4
npm notice Run npm install -g npm#8.1.4 to update!
npm notice
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: artemis#0.1.0
npm ERR! Found: vue#3.2.22
npm ERR! node_modules/vue
npm ERR! vue#"^3.0.0" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer vue#"^2.5.17" from element-ui#2.15.6
npm ERR! node_modules/element-ui
npm ERR! element-ui#"^2.15.6" 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 /root/.npm/eresolve-report.txt for a full report.
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2021-11-25T01_40_08_953Z-debug.log
but this package.json work well on node:lts-alpine base image
It seems that you have problems with peer dependencies, if you just set your npm to use legacy dependency logic to install your packages you will solve the problem.
Just add to your Dockerfile this setting before running npm install:
...
COPY package.json /home
RUN npm config set legacy-peer-deps true
RUN npm install --prefix /home
To understand what this flag does I suggest you read this SO answer where it is explained extensively.

Locally installed NPM module commands can't be found

For any scripts that are set up in my package.json file for modules installed locally, npm says it cannot find the command.
Below is my package.json. I have already run an ‘npm install` without any issues installing the packages.
{
"name": "app",
"private": true,
"dependencies": {
"#babel/core": "^7.8.6",
"#babel/preset-env": "^7.8.6",
"#babel/preset-react": "^7.8.3",
"babel-loader": "^8.0.6",
"bootstrap": "^4.4.1",
"jquery": "^1.9.1",
"react": "^16.13.0",
"react-dom": "^16.13.0",
"react-owl-carousel": "^2.3.1",
"react-redux": "^7.2.0",
"react-router-dom": "^5.1.2",
"react-slick": "^0.25.2",
"reactstrap": "^8.4.1",
"redux": "^4.0.5",
"redux-logger": "^3.0.6",
"redux-thunk": "^2.3.0",
"slick-carousel": "^1.8.1",
"webpack-cli": "^3.3.11"
},
"scripts": {
"postinstall": "webpack",
"start": "webpack --watch --mode=development"
},
"engines": {
"node": "10.13.0",
"npm": "6.4.1"
},
"devDependencies": {
"css-loader": "^3.4.2",
"style-loader": "^1.1.3",
"webpack": "^4.42.0"
}
}
When I try to run npm start from the root file, I get these errors:
sh: webpack: command not found
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! app# start: `webpack --watch --mode=development`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the app# start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
I have this same problem across multiple projects. If I install globally it will work, but from what I understand with webpack, that should not be necessary and is discouraged: https://webpack.js.org/guides/installation/#global-installation.
Any ideas what the trouble may be here? Thanks!
The issue was the directory my app was located in had a / in the directory name (e.g. a/b > app > node_modules). The / is interpreted as a : and npm doesn't like that.

Unable to install node in Heroku

I am trying to deploy a Django Application on Heroku with the node and npm installations, however, while deploying the application I get the following error on the Heroku console:
npm ERR! node v11.13.0
npm ERR! npm v2.15.12
npm ERR! path /tmp/build_number/node_modules/.bin/grunt
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall unlink
npm ERR! enoent ENOENT: no such file or directory, unlink '/tmp/build_number/node_modules/.bin/grunt'
npm ERR! enoent This is most likely not a problem with npm itself
npm ERR! enoent and is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! Please include the following file with any support request:
npm ERR! /tmp/build_number/npm-debug.log
-----> Build failed
I am trying to build charts using Vue.js components that uses buildpacks. I would like to know how to install the npm on Heroku. Any help will be greatly appreciated.
I have the following configuration for the website:
Django version: 2.1.7
Node Version: 11.3.0
Python Version: 3.7.3
My package.json file looks as follows:
{
"name": "django",
"private": true,
"scripts": {
"start": "node app",
"poststart": "npm prune --production",
"pretest": "eslint django/ js_tests/admin/ js_tests/gis/",
"test": "grunt test --verbose"
},
"engines": {
"node": "11.13.0",
"npm": ">=1.3.0 <3.0.0",
"build": "bower install && grunt build",
"start": "nf start"
},
"devDependencies": {
"#babel/core": "^7.4.3",
"#babel/plugin-transform-runtime": "^7.4.3",
"#babel/preset-env": "^7.4.3",
"#babel/runtime": "^7.4.3",
"axios": "^0.18.0",
"babel-loader": "^8.0.5",
"babel-preset-es2015": "^6.24.1",
"babel-preset-stage-0": "^6.24.1",
"bootstrap-sass": "^3.4.1",
"css-loader": "^2.1.1",
"eslint": "^5.16.0",
"grunt": "^1.0.1",
"grunt-cli": "^1.2.0",
"grunt-contrib-qunit": "^1.2.0",
"jquery": "^3.3.1",
"node-sass": "^4.11.0",
"sass-loader": "^7.1.0",
"style-loader": "^0.23.1",
"vue": "^2.6.10",
"vue-hot-reload-api": "^2.3.3",
"vue-loader": "^15.7.0",
"vue-template-compiler": "^2.6.10",
"webpack": "^4.29.6",
"webpack-bundle-tracker": "^0.4.2-beta",
"webpack-cli": "^3.3.0"
},
"description": "FitGirl Inc",
"version": "1.0.0",
"main": "index.js",
"repository": {
"type": "git",
"url": "git+https://github.com/uno-isqa-8950/fitgirl-inc.git"
},
"author": "hghanta",
"license": "ISC",
"bugs": {
"url": "https://github.com/uno-isqa-8950/fitgirl-inc/issues"
},
"homepage": "https://github.com/uno-isqa-8950/fitgirl-inc#readme",
"dependencies": {
"chart.js": "^2.8.0",
"vue-chartjs": "^3.4.2",
"vue-cli": "^2.9.6"
},
"keywords": [
"djano"
]
}
My ProcFile is as follows:
web: node node_modules/gulp/bin/gulp build, gunicorn empoweru.wsgi:application --log-file -
'''
Heroku by default has it's Node modules cache enabled. So when you try to make changes to your package.json Heroku does not recognize your changes to the devDependencies. Follow these two steps and you should be able to deploy it:
Remove grunt-cli from your devDependencies
Run this command to disable cache
heroku config:set NODE_MODULES_CACHE=false
Deploy your code

npm fails when installing gulp-typescript on Azure

I'm trying to deploy my Azure AppService. The application is written using TypeScript (both server and client). When deploying everything works ok until it's installing gulp-typescript. This is used to transpile TypeScript code as part of postinstall script.
Package.json:
{
"name": "test-webapp",
"version": "1.0.0",
"description": "Test Application",
"engines": {
"node": "4.4.6"
},
"main": "server.js",
"scripts": {
"start": "node server/server.js",
"typings": "typings",
"postinstall": "node node_modules/bower/bin/bower install && npm run typings install && node node_modules/gulp/bin/gulp.js ts-compile"
},
"author": {
"name": "liskaj",
"email": ""
},
"dependencies": {
"body-parser": "^1.15.2",
"bower": "^1.7.9",
"cors": "^2.7.1",
"express": "^4.14.0",
"express-session": "^1.14.0",
"gulp": "^3.9.1",
"gulp-sourcemaps": "^1.6.0",
"gulp-typescript": "^2.13.6",
"request": "^2.73.0",
"typescript": "^1.8.10",
"typings": "^1.3.2",
"winston": "^2.2.0"
}
}
Azure log output:
remote: npm ERR! node v4.4.6
remote: npm ERR! npm v2.15.5
remote: npm ERR! path D:\home\site\wwwroot\node_modules\gulp-typescript\node_modules\vinyl-fs\node_modules\globstream\node_modules\micromatch\node_modules\braces\node_modules\expand-range\node_modules\fill-range\node_modules\isobject\node_modules\isarray\package.json.3240780430
remote: npm ERR! code EINVAL
remote: npm ERR! errno -4071
remote: npm ERR! syscall rename
remote:
remote: npm ERR! EINVAL: invalid argument, rename 'D:\home\site\wwwroot\node_modules\gulp-typescript\node_modules\vinyl-fs\node_modules\glob-stream\node_modules\micromatch\node_modules\braces\node_modules\expand-range\node_modules\fill-range\node_modules\isobject\node_modules\isarray\package.json.3240780430' -> 'D:\home\site\wwwroot\node_modules\gulp-typescript\node_modules\vinyl-fs\node_modules\glob-stream\node_modules\micromatch\node_modules\braces\node_modules\expand-range\node_modules\fill-range\node_modules\isobject\node_modules\isarray\package.json
This works fine locally (Windows 7 + Windows 10) and also on Heroku.

Resources