Npm prepublish script webpack not found - node.js

I am trying to modify a npm module and I want to include the modified module as a local dependency.
When deploying this app on hosting, I am facing a strange webpack not found problem. I managed to reproduce the problem in my local machine by removing webpack globally.
My package.json:
1) I try to include the local module in package.json dependencies:
{
"name": "parse-server-example",
"version": "1.4.0",
"description": "An example Parse API server using the parse-server module",
"main": "index.js",
"repository": {
"type": "git",
"url": "https://github.com/ParsePlatform/parse-server-example"
},
"license": "MIT",
"dependencies": {
"webpack": "2.3.3",
"express": "~4.11.x",
"kerberos": "~0.0.x",
"parse": "~1.8.0",
"parse-dashboard-simple": "./parse-dashboard-simple",
"parse-server": "*"
},
"scripts": {
"start": "node index.js"
},
"engines": {
"node": "7.6.0"
}
}
Take note that I have a local module called "./parse-dashboard-simple".
My local module's package.json:
{
"name": "parse-dashboard",
"parseDashboardFeatures": [
"Data Browser",
"Cloud Code Viewer",
"Cloud Code Jobs Viewer and Runner",
"Parse Config",
"API Console",
"Class Level Permissions Editor",
"Pointer Permissions Editor",
"Send Push Notifications",
"Logs Viewer",
"Push Status Page",
"Relation Editor"
],
"description": "The Parse Dashboard",
"keywords": [
"parse",
"dashboard"
],
"homepage": "https://github.com/ParsePlatform/parse-dashboard",
"bugs": "https://github.com/ParsePlatform/parse-dashboard/issues",
"version": "1.0.25",
"repository": {
"type": "git",
"url": "https://github.com/ParsePlatform/parse-dashboard"
},
"license": "SEE LICENSE IN LICENSE",
"files": [
"Parse-Dashboard",
"bin",
"README.md",
"LICENSE"
],
"dependencies": {
"bcryptjs": "^2.3.0",
"body-parser": "^1.15.2",
"commander": "^2.9.0",
"connect-flash": "^0.1.1",
"cookie-session": "^2.0.0-alpha.1",
"csurf": "^1.9.0",
"express": "^4.13.4",
"json-file-plus": "^3.2.0",
"package-json": "^2.3.1",
"passport": "^0.3.2",
"passport-local": "^1.0.0",
"webpack": "~1.12.0"
},
"devDependencies": {
"babel-core": "~5.8.12",
"babel-loader": "~5.3.0",
"babel-plugin-remove-proptypes": "~1.0.0",
"babel-polyfill": "^6.7.2",
"babel-runtime": "~5.8.25",
"css-loader": "~0.18.0",
"file-loader": "^0.8.5",
"history": "^2.1.2",
"http-server": "~0.8.5",
"immutable": "~3.7.5",
"immutable-devtools": "~0.0.4",
"jest-cli": "^12.0.2",
"js-beautify": "~1.5.0",
"marked": "^0.3.5",
"node-sass": "^3.7.0",
"parse": "1.6.14",
"prismjs": "~1.2.0",
"react": "^15.0.1",
"react-addons-test-utils": "^15.0.1",
"react-dnd": "~2.1.4",
"react-dnd-html5-backend": "~2.0.0",
"react-dom": "^15.0.1",
"react-router": "^2.6.0",
"request-promise": "^4.1.1",
"sass-loader": "~3.1.2",
"style-loader": "~0.12.3",
"svg-prep": "~1.0.0",
"transform-jest-deps": "^2.1.0",
"webpack": "~1.12.0"
},
"scripts": {
"dev": "node ./Parse-Dashboard/index.js & webpack --config webpack/build.config.js --devtool eval-source-map --progress --watch",
"dashboard": "node ./Parse-Dashboard/index.js & webpack --config webpack/build.config.js --progress --watch",
"pig": "http-server ./PIG -p 4041 -s & webpack --config webpack/PIG.config.js --progress --watch",
"build": "NODE_ENV=production webpack --config webpack/production.config.js && webpack --config webpack/PIG.config.js",
"test": "NODE_PATH=./node_modules jest",
"generate": "node scripts/generate.js",
"prepublish": "webpack --config webpack/publish.config.js",
"start": "node ./Parse-Dashboard/index.js"
},
"bin": {
"parse-dashboard": "./bin/parse-dashboard"
},
"engines": {
"node": "7.6.0"
},
"main": "Parse-Dashboard/app.js",
"jest": {
"testPathDirs": [
"src/lib"
],
"scriptPreprocessor": "<rootDir>/testing/preprocessor.js",
"testDirectoryName": "tests",
"testFileExtensions": [
"test.js"
],
"unmockedModulePathPatterns": [
"react",
"react-dom",
"react-addons-test-utils",
"fbjs"
]
}
}
If I run "npm install" at the root level of this project, I will get this error:
npm WARN prepublish-on-install As of npm#5, `prepublish` scripts will run only for `npm publish`.
npm WARN prepublish-on-install (In npm#4 and previous versions, it also runs for `npm install`.)
npm WARN prepublish-on-install See the deprecation note in `npm help scripts` for more information.
> parse-dashboard#1.0.25 prepublish /mypath/-dashboard-advanced
> webpack --config webpack/publish.config.js
sh: webpack: command not found
npm ERR! addLocal Could not install /mypath/-dashboard-advanced
npm ERR! addLocal Could not install /mypath/-dashboard-simple
npm WARN Local package.json exists, but node_modules missing, did you mean to install?
npm ERR! Darwin 16.5.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install"
npm ERR! node v7.6.0
npm ERR! npm v4.1.2
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! parse-dashboard#1.0.25 prepublish: `webpack --config webpack/publish.config.js`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the parse-dashboard#1.0.25 prepublish script 'webpack --config webpack/publish.config.js'.
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 parse-dashboard package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! webpack --config webpack/publish.config.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs parse-dashboard
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls parse-dashboard
npm ERR! There is likely additional logging output above.
So my understanding is that the webpack is needed in prepublish script but it is not found. But I have intentionally added webpack as dependencies in both root project or the local module (in both dev and production dependencies just to be safe), why is webpack still not found?

Related

'npm install' does not work on a nodejs project in a plesk

I'm trying to deploy my nodejs project on my plesk server but something went wrong.
Even if everything works fine on localhost, I can not install npm on the plesk and I don't know why.
Here is my package.json :
{
"name": "node-mysql-boilerplate",
"version": "1.0.7",
"description": "node-mysql-boilerplate",
"main": "app.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node app.js"
},
"dependencies": {
"#cosmjs/encoding": "^0.28.11",
"#elrondnetwork/elrond-core-js": "^2.1.0",
"#elrondnetwork/erdjs": "^10.2.5",
"#elrondnetwork/erdjs-network-providers": "^0.1.5",
"#elrondnetwork/erdjs-walletcore": "^1.0.0",
"ajv": "^5.5.2",
"artillery": "^2.0.0-16",
"axios": "^0.27.2",
"bcrypt": "^3.0.8",
"bcryptjs": "*",
"bech32-converting": "^1.0.9",
"body-parser": "*",
"cors": "*",
"express": "^4.18.1",
"flatted": "^3.2.6",
"fs": "^0.0.1-security",
"ipfs-api": "^26.1.2",
"ipfs-http-client": "^57.0.3",
"jsonwebtoken": "^8.5.1",
"mysql": "^2.18.1",
"node-schedule": "^1.3.0",
"nodemailer": "^6.7.5",
"nodemon": "^1.19.4",
"pm2": "^2.10.4",
"react": "^18.1.0",
"to-hex": "^0.0.18"
},
"author": "",
"license": "ISC"
}
Here is the error message on npm install process :
npm ERR! code 127
npm ERR! path /var/www/vhosts/apcom.app/elrond-api.apcom.app/node_modules/peer-id/node_modules/ursa-optional
npm ERR! command failed
npm ERR! command sh -c node rebuild.js
npm ERR! sh: 1: node: Permission denied
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2022-07-28T14_46_54_171Z-debug.log
My node version and npm version in the plesk
node -v # v16.13.0
npm -v # 8.1.0
Here is the link to the boilerplate I use for this nodejs project :
https://github.com/yug95/node-mysql
I have tried this, but nothing changes :
npm config set user 0
npm config set unsafe-perm true
and
rm -rf node_modules # Delete node_modules folder
npm install # Retry to install

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

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 scripts in package.json errors on exit

I'm able to run my scripts successfully, however, when i exit (ctrl + c) I get a loud error from the eslint, or jest jobs that were watching. Is there a means of suppressing these, as I get errors from the package themselves when the tests or linting fails
Example error:
npm ERR! Darwin 15.6.0
npm ERR! argv "/usr/local/Cellar/node/7.5.0/bin/node" "/usr/local/bin/npm" "run" "lint"
npm ERR! node v7.5.0
npm ERR! npm v4.1.2
npm ERR! code ELIFECYCLE
npm ERR! wpauth#1.0.0 lint: `esw webpack.config.* src tools --color`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the wpauth#1.0.0 lint script 'esw webpack.config.* src tools --color'.
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 wpauth package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! esw webpack.config.* src tools --color
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs wpauth
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls wpauth
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /Users/gazzwi86/Sites/tokenauth/npm-debug.log
Package.json
{
"name": "wpauth",
"version": "1.0.0",
"scripts": {
"start": "npm run start:dev",
"start:dev": "npm-run-all --parallel test:watch lint:watch serve:dev open:dev",
"start:dist": "npm-run-all build open:dist serve:dist",
"prebuild": "rm -r src/main/webapp/public/secure-me && mkdir src/main/webapp/public/secure-me && npm run test && npm run lint",
"build": "webpack -p --define process.env.NODE_ENV='\"production\"' --optimize-minimize && cp ./src/ui/index.html src/main/webapp/public/secure-me/",
"lint": "esw webpack.config.* src tools --color",
"lint:watch": "npm run lint -- --watch",
"test": "jest",
"test:watch": "npm run test -- --watch",
"open:dev": "open http://localhost:8080/webpack-dev-server/",
"open:dist": "open http://localhost:8080/",
"serve:dev": "webpack-dev-server --progress --colors --content-base src/ui",
"serve:dist": "http-server src/main/webapp/public/secure-me"
},
"jest": {
"moduleNameMapper": {
"\\.(css|scss)$": "identity-obj-proxy",
"^.+\\.(gif|ttf|eot|svg|woff|woff2|ico)$": "<rootDir>/fileMock.js"
}
},
"dependencies": {
"backbone": "^1.3.3",
"jquery": "^2.2.4",
"react": "^15.4.2",
"react-dom": "^15.4.2",
"underscore": "^1.8.3"
},
"devDependencies": {
"babel-core": "^6.22.1",
"babel-eslint": "^7.1.1",
"babel-jest": "^18.0.0",
"babel-loader": "^6.2.1",
"babel-plugin-transform-class-properties": "^6.23.0",
"babel-polyfill": "^6.23.0",
"babel-preset-es2015": "^6.22.0",
"babel-preset-react": "^6.3.13",
"css-loader": "^0.26.1",
"enzyme": "^2.7.1",
"eslint": "^3.15.0",
"eslint-plugin-import": "^2.2.0",
"eslint-plugin-react": "^6.9.0",
"eslint-watch": "^2.1.14",
"http-server": "^0.9.0",
"image-webpack-loader": "^3.2.0",
"jest-cli": "^18.1.0",
"npm-run-all": "3.1.2",
"open": "0.0.5",
"react-addons-test-utils": "^15.4.2",
"sinon": "^1.17.7",
"style-loader": "^0.13.1",
"webpack": "^2.2.1",
"webpack-dev-server": "^2.3.0"
}
}

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