MEAN NPM Cannot find module 'webpack/lib/optimize/CommonsChunkPlugin' Error - node.js

I am having a little bit of problem upgrading to latest webpack. I have already checked the following threads and found that the cause of the error is a deprecated class.
Webpack migration 3 -> 4: Error: Cannot find module 'webpack/lib/optimize/CommonsChunkPlugin'
Webpack 4 migration CommonsChunkPlugin
The only problem is that I am not using this class in my code but even though I updated it, webpack itself is referencing it somewhere.
Note: I have already tried removing the node_modules, clearing cache and reinstalling
I generated the package.json through MEAN and the start script that is in the package.json use is referencing a bunch of webpack scripts which might be the issue.
One thing that is interesting is the following warning, tho, I am not sure if it is related:
preload-webpack-plugin#2.3.0 requires a peer of webpack#^3.2.0 but none is installed. You must install peer dependencies yourself.
It is saying a version higher then 3.2.0 is required (I have 4.2.0). I am not sure if it is because it is not recognizing the WebpackV4 or if V4 is just not backward compatible
current node version: 9.8.0
I appreciate any ideas/suggestions. package.json and the full error is below. Please let me know if I can provide any further info
[0] > Mean#2.0.1 server:dev /Users/Sinan/Desktop/cllctroffcl
[0] > npm run webpack-dev-server -- --config config/webpack.dev.js --open --
progress --profile --watch --content-base src/
[0]
[0]
[0] > Mean#2.0.1 webpack-dev-server /Users/Sinan/Desktop/cllctroffcl
[0] > node --max_old_space_size=4096 node_modules/webpack-dev-
server/bin/webpack-dev-server.js "--config" "config/webpack.dev.js" "--open" "--progress" "--profile" "--watch" "--content-base" "src/"
[0]
[1] PC listening on 8888
[0] module.js:545
[0] throw err;
[0] ^
[0]
[0] Error: Cannot find module 'webpack/lib/optimize/CommonsChunkPlugin'
[0] at Function.Module._resolveFilename (module.js:543:15)
[0] at Function.Module._load (module.js:470:25)
[0] at Module.require (module.js:593:17)
[0] at require (internal/module.js:11:18)
[0] at Object.<anonymous>
(/Users/Sinan/Desktop/cllctroffcl/config/webpack.common.js:16:28)
[0] at Module._compile (module.js:649:30)
[0] at Object.Module._extensions..js (module.js:660:10)
[0] at Module.load (module.js:561:32)
[0] at tryModuleLoad (module.js:501:12)
[0] at Function.Module._load (module.js:493:3)
[0] npm ERR! code ELIFECYCLE
[0] npm ERR! errno 1
[0] npm ERR! Mean#2.0.1 webpack-dev-server: `node --max_old_space_size=4096
node_modules/webpack-dev-server/bin/webpack-dev-server.js "--config"
"config/webpack.dev.js" "--open" "--progress" "--profile" "--watch" "--
content-base" "src/"`
[0] npm ERR! Exit status 1
[0] npm ERR!
npm ERR! Failed at the Mean#2.0.1 webpack-dev-server script.
[0] npm ERR! This is probably not a problem with npm. There is likely
additional logging output above.
[0]
[0] npm ERR! A complete log of this run can be found in:
[0] npm ERR! /Users/Sinan/.npm/_logs/2018-03-26T03_43_37_514Z-debug.log
[0] npm ERR! code ELIFECYCLE
[0] npm ERR! errno 1
[0] npm ERR! Mean#2.0.1 server:dev: `npm run webpack-dev-server -- --config
config/webpack.dev.js --open --progress --profile --watch --content-base
src/`
[0] npm ERR! Exit status 1
[0] npm ERR!
[0] npm ERR! Failed at the Mean#2.0.1 server:dev script.
npm ERR! This is probably not a problem with npm. There is likely additional
logging output above.
[0]
[0] npm ERR! A complete log of this run can be found in:
[0] npm ERR! /Users/Sinan/.npm/_logs/2018-03-26T03_43_37_532Z-debug.log
[0] npm run server:dev exited with code 1
Package.json
{
"name": "Mean",
"version": "2.0.1",
"description": "A MEAN stack framework using Angular Webpack Starter kit - featuring Angular (Router, Http, Forms, Services, Tests, E2E, Coverage), Karma, Protractor, Jasmine, Istanbul, TypeScript, and Webpack",
"keywords": [
"angular",
"angular2",
"angular4",
"webpack",
"typescript"
],
"author": "Lior Kesos <lior#linnovate.net>",
"homepage": "http://mean.io",
"license": "MIT",
"scripts": {
"build:aot:prod": "npm run clean:dist && npm run clean:aot && cross-env BUILD_AOT=1 npm run webpack -- --config config/webpack.prod.js --progress --profile --bail",
"build:aot": "npm run build:aot:prod",
"build:dev": "npm run clean:dist && npm run webpack -- --config config/webpack.dev.js --progress --profile",
"build:docker": "npm run build:prod && docker build -t angular2-webpack-start:latest .",
"build:prod": "npm run clean:dist && npm run webpack -- --config config/webpack.prod.js --progress --profile --bail",
"build": "npm run build:dev",
"ci:aot": "npm run lint && npm run test && npm run build:aot && npm run e2e",
"ci:jit": "npm run lint && npm run test && npm run build:prod && npm run e2e",
"ci:nobuild": "npm run lint && npm test && npm run e2e",
"ci:testall": "npm run lint && npm run test && npm run build:prod && npm run e2e && npm run build:aot && npm run e2e",
"ci:travis": "npm run lint && npm run test && npm run build:aot && npm run e2e:travis",
"ci": "npm run ci:testall",
"clean:dll": "npm run rimraf -- dll",
"clean:aot": "npm run rimraf -- compiled",
"clean:dist": "npm run rimraf -- dist",
"clean:install": "npm set progress=false && npm install",
"clean": "npm cache clean && npm run rimraf -- node_modules doc coverage dist compiled dll",
"docker": "docker",
"docs": "npm run typedoc -- --options typedoc.json --exclude '**/*.spec.ts' ./src/",
"e2e:live": "npm-run-all -p -r server:prod:ci protractor:live",
"e2e:travis": "npm-run-all -p -r server:prod:ci protractor:delay",
"e2e": "npm-run-all -p -r server:prod:ci protractor",
"github-deploy:dev": "npm run webpack -- --config config/webpack.github-deploy.js --progress --profile --env.githubDev",
"github-deploy:prod": "npm run webpack -- --config config/webpack.github-deploy.js --progress --profile --env.githubProd",
"github-deploy": "npm run github-deploy:dev",
"lint": "npm run tslint \"src/**/*.ts\"",
"node": "node",
"postinstall": "npm run webdriver:update",
"postversion": "git push && git push --tags",
"preclean:install": "npm run clean",
"preversion": "npm test",
"protractor": "protractor",
"protractor:delay": "sleep 3 && npm run protractor",
"protractor:live": "protractor --elementExplorer",
"rimraf": "rimraf",
"server:dev:hmr": "npm run server:dev -- --inline --hot",
"server:dev": "npm run webpack-dev-server -- --config config/webpack.dev.js --open --progress --profile --watch --content-base src/",
"server:prod": "http-server dist -c-1 --cors",
"server:prod:ci": "http-server dist -p 3000 -c-1 --cors",
"server": "npm run server:dev",
"start:hmr": "npm run server:dev:hmr",
"start": "concurrently \"npm run server:dev\" \"nodemon --watch server server-start.js\" ",
"start:prod": "NODE_ENV=production node server-start.js",
"test": "npm run lint && karma start",
"tslint": "tslint",
"typedoc": "typedoc",
"version": "npm run build",
"watch:dev:hmr": "npm run watch:dev -- --hot",
"watch:dev": "npm run build:dev -- --watch",
"watch:prod": "npm run build:prod -- --watch",
"watch:test": "npm run test -- --auto-watch --no-single-run",
"watch": "npm run watch:dev",
"webdriver-manager": "webdriver-manager",
"webdriver:start": "npm run webdriver-manager start",
"webdriver:update": "webdriver-manager update",
"webpack-dev-server": "node --max_old_space_size=4096 node_modules/webpack-dev-server/bin/webpack-dev-server.js",
"webpack": "node --max_old_space_size=4096 node_modules/webpack/bin/webpack.js"
},
"dependencies": {
"#angular/animations": "~5.2.9",
"#angular/cdk": "~5.2.4",
"#angular/common": "^5.0.0",
"#angular/compiler": "~5.2.9",
"#angular/core": "^5.0.0",
"#angular/forms": "~5.2.9",
"#angular/http": "~5.2.9",
"#angular/material": "~5.2.4",
"#angular/platform-browser": "~5.2.9",
"#angular/platform-browser-dynamic": "~5.2.9",
"#angular/platform-server": "~5.2.9",
"#angular/router": "~5.2.9",
"#angularclass/hmr": "~2.1.3",
"#angularclass/hmr-loader": "~3.0.2",
"#ng-select/ng-select": "^0.30.1",
"#reactivex/rxjs": "^5.4.3",
"angular-in-memory-web-api": "~0.6.0",
"angular2-universal": "2.1.0-rc.1",
"apollo-angular": "^1.0.1",
"apollo-client": "^1.4.2",
"app-root-path": "^2.0.1",
"babel-cli": "^6.24.1",
"body-parser": "^1.17.2",
"casual": "^1.5.14",
"cookie-parser": "^1.4.3",
"core-js": "^2.4.1",
"cors": "^2.8.3",
"dotenv": "^5.0.1",
"express": "^4.15.3",
"express-graphql": "^0.6.6",
"express-jwt": "^5.3.0",
"express-validation": "^1.0.2",
"express-winston": "^2.4.0",
"graphql": "^0.13.2",
"graphql-server-express": "latest",
"graphql-tag": "^2.2.2",
"graphql-tools": "^2.23.1",
"hammerjs": "^2.0.8",
"helmet": "^3.6.1",
"hll": "^1.1.0",
"http-server": "^0.11.1",
"http-status": "^1.0.1",
"ie-shim": "^0.1.0",
"innograph": "git://github.com/linnovate/innograph.git#devel",
"joi": "^13.1.2",
"jsonwebtoken": "^8.1.0",
"long": "^4.0.0",
"material": "^0.2.6",
"method-override": "^2.3.9",
"mongoose": "^5.0.11",
"mongoose-double": "0.0.1",
"morgan": "^1.8.2",
"ng2-go-top-button": "^4.1.0",
"ngx-carousel": "^1.3.5",
"passport": "^0.4.0",
"passport-local": "^1.0.0",
"preboot": "^5.0.0-rc.10",
"react": "^16.2.0",
"react-dom": "^16.2.0",
"reflect-metadata": "^0.1.10",
"rxjs": "^5.4.3",
"sockjs-client": "^1.1.4",
"winston": "^2.3.1",
"zone.js": "latest"
},
"devDependencies": {
"#angular/compiler-cli": "~5.2.9",
"#ngtools/webpack": "^1.10.2",
"#types/hammerjs": "^2.0.34",
"#types/jasmine": "2.8.6",
"#types/node": "^9.6.0",
"#types/source-map": "^0.5.0",
"#types/uglify-js": "^3.0.0",
"#types/webpack": "^4.1.2",
"add-asset-html-webpack-plugin": "^2.1.3",
"angular2-template-loader": "^0.6.2",
"assets-webpack-plugin": "^3.5.1",
"awesome-typescript-loader": "~4.0.1",
"babel-core": "^6.26.0",
"babel-loader": "^7.1.2",
"babel-plugin-syntax-async-functions": "^6.13.0",
"babel-plugin-transform-es2015-destructuring": "^6.23.0",
"babel-plugin-transform-object-rest-spread": "^6.23.0",
"babel-polyfill": "^6.23.0",
"babel-preset-es2015": "^6.24.1",
"babel-preset-es2017": "^6.24.1",
"babel-preset-react": "^6.24.1",
"babel-register": "^6.24.1",
"codelyzer": "~4.2.1",
"concurrently": "^3.4.0",
"copy-webpack-plugin": "^4.0.1",
"cross-env": "^5.0.0",
"css-loader": "^0.28.0",
"exports-loader": "^0.7.0",
"expose-loader": "^0.7.3",
"extract-text-webpack-plugin": "~3.0.2",
"file-loader": "^1.1.11",
"find-root": "^1.0.0",
"gh-pages": "^1.1.0",
"html-webpack-plugin": "^3.1.0",
"imports-loader": "^0.8.0",
"inline-manifest-webpack-plugin": "^3.0.1",
"istanbul-instrumenter-loader": "3.0.0",
"jasmine-core": "^3.1.0",
"json-loader": "^0.5.4",
"karma": "^2.0.0",
"karma-chrome-launcher": "^2.0.0",
"karma-coverage": "^1.1.1",
"karma-jasmine": "^1.1.0",
"karma-mocha-reporter": "^2.2.3",
"karma-remap-coverage": "^0.1.4",
"karma-sourcemap-loader": "^0.3.7",
"karma-webpack": "~3.0.0",
"ng-router-loader": "^2.1.0",
"ngc-webpack": "~4.1.2",
"node-sass": "^4.5.2",
"nodemon": "^1.11.0",
"npm-run-all": "^4.0.2",
"optimize-js-plugin": "0.0.4",
"parse5": "^4.0.0",
"preload-webpack-plugin": "^2.3.0",
"protractor": "^5.1.1",
"raw-loader": "0.5.1",
"rimraf": "~2.6.1",
"sass-loader": "^6.0.3",
"script-ext-html-webpack-plugin": "^2.0.1",
"source-map-loader": "^0.2.1",
"string-replace-loader": "~2.1.1",
"style-loader": "~0.20.3",
"to-string-loader": "^1.1.5",
"ts-node": "~5.0.1",
"tslib": "^1.6.1",
"tslint": "~5.9.1",
"tslint-loader": "^3.5.2",
"typedoc": "^0.11.1",
"typescript": "~2.7.2",
"url-loader": "~1.0.1",
"webpack": "~4.2.0",
"webpack-cli": "^2.0.13",
"webpack-dev-middleware": "~3.0.1",
"webpack-dev-server": "^3.1.1",
"webpack-dll-bundles-plugin": "^1.0.0-beta.5",
"webpack-merge": "~4.1.0"
},
"repository": {
"type": "git",
"url": "https://github.com/AngularClass/angular-starter.git"
},
"bugs": {
"url": "https://github.com/AngularClass/angular-starter/issues"
},
"engines": {
"node": ">= 4.2.1",
"npm": ">= 3"
}
}

I just realized this was not a very well thought question however since other people might run into this I will keep the question up.
The problem is that config/webpack.common.js is out of date and tries to call on this deprecated class.
For a temporary work around is to comment out the following sections from config/webpack.common.js
const CommonsChunkPlugin = require('webpack/lib/optimize/CommonsChunkPlugin');
const ScriptExtHtmlWebpackPlugin = require('script-ext-html-webpack-plugin');
AND
new CommonsChunkPlugin({
name: 'vendor',
chunks: ['main'],
minChunks: module => /node_modules/.test(module.resource)
}),
new ScriptExtHtmlWebpackPlugin({
sync: /polyfill|vendor/,
defaultAttribute: 'async',
preload: [/polyfill|vendor|main/],
prefetch: [/chunk/]
As of webpack4, tsConfigPath, is required to be specified.
You will also need to go under
ngcWebpack.NgcWebpackPlugin
and add
tsConfigPath: 'tsconfig.webpack.json',
ScriptExtHtmlWebpack seems to be an external library they use, which is also broken under webpack 4.
Note: Obviously commenting out all these things will have effects on your project. Just want to repeat once again that this is a temporary work around if you absolutely must use web pack 4.
I created a feature request that you can track here
Hopefully the config file will be updated as the transition to MEAN 2 takes place
Hope this helps

Related

heroku sh: 1: tsc: not found

this my scripts
{
"name": "fullstack-apollo-express-boilerplate-project",
"version": "1.0.0",
"description": "",
"main": "index.ts",
"scripts": {
"tsc": "./node_modules/typescript/bin/tsc",
"build": "rimraf ./build && tsc",
"dev": "nodemon",
"start": "npm run build && node build/index.js",
"codegen": "graphql-codegen --config ./codegen.yml",
"lint": "eslint . --ext .ts",
"lint-and-fix": "eslint . --ext .ts --fix",
"prettier-format": "prettier --config .prettierrc src/**/*.ts --write"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"#graphql-codegen/cli": "^2.3.0",
"#graphql-codegen/typescript": "^2.4.1",
"#graphql-codegen/typescript-resolvers": "^2.4.2",
"#shopify/eslint-plugin": "^41.0.1",
"#types/bcryptjs": "^2.4.2",
"#types/cookie-parser": "^1.4.2",
"#types/mongoose-lean-virtuals": "^0.5.2",
"#types/nodemailer": "^6.4.4",
"#types/uuid": "^8.3.3",
"#typescript-eslint/eslint-plugin": "^5.5.0",
"#typescript-eslint/parser": "^5.5.0",
"eslint": "^8.4.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-import": "^2.25.3",
"eslint-plugin-prettier": "^4.0.0",
"nodemon": "^2.0.15",
"prettier": "^2.5.1",
"ts-node": "^10.4.0",
"typescript": "^4.5.2"
},
"dependencies": {
"#types/express": "^4.17.13",
"#types/node": "^16.11.11",
"apollo-server-core": "^3.5.0",
"apollo-server-express": "^3.5.0",
"bcryptjs": "^2.4.3",
"cookie-parser": "^1.4.6",
"cors": "^2.8.5",
"crypto-random-string": "3.3.1",
"dotenv": "^10.0.0",
"express": "^4.17.1",
"express-openid-connect": "^2.5.1",
"graphql": "^16.0.1",
"graphql-fields-list": "^2.2.4",
"graphql-parse-resolve-info": "^4.12.0",
"graphql-voyager": "^1.0.0-rc.31",
"i": "^0.3.7",
"jsonwebtoken": "^8.5.1",
"moment": "^2.29.1",
"mongoose": "^6.0.14",
"mongoose-lean-virtuals": "^0.9.0",
"nodemailer": "^6.7.2",
"rimraf": "^3.0.2"
}
}
when i do deploy i get error
2022-01-14T08:20:20.950719+00:00 app[web.1]: sh: 1: tsc: not found
2022-01-14T08:20:20.956238+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2022-01-14T08:20:20.956684+00:00 app[web.1]: npm ERR! syscall spawn
2022-01-14T08:20:20.956866+00:00 app[web.1]: npm ERR! file sh
2022-01-14T08:20:20.956950+00:00 app[web.1]: npm ERR! errno ENOENT
2022-01-14T08:20:20.961092+00:00 app[web.1]: npm ERR! fullstack-apollo-express-boilerplate-project#1.0.0 build: `rimraf ./build && tsc`
2022-01-14T08:20:20.961191+00:00 app[web.1]: npm ERR! spawn ENOENT
2022-01-14T08:20:20.961291+00:00 app[web.1]: npm ERR!
2022-01-14T08:20:20.961337+00:00 app[web.1]: npm ERR! Failed at the fullstack-apollo-express-boilerplate-project#1.0.0 build script.
2022-01-14T08:20:20.961377+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2022-01-14T08:20:20.961191+00:00 app[web.1]: npm ERR! spawn ENOENT
2022-01-14T08:20:20.961291+00:00 app[web.1]: npm ERR!
2022-01-14T08:20:20.961337+00:00 app[web.1]: npm ERR! Failed at the fullstack-apollo-express-boilerplate-project#1.0.0 build script.
2022-01-14T08:20:20.961377+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
I can't figure out what's the reason Everything works fine for me.
If you don't have a Procfile, Heroku will run your start script as a web process.
Your start script runs your build script, and your build script compiles your app using tsc:
"build": "rimraf ./build && tsc",
"start": "npm run build && node build/index.js",
// ^^^^^^^^^^^^^
This causes Heroku to try to compile your app every time your dyno starts, and since typescript is (correctly) a devDependency, tsc isn't available at runtime.
It doesn't make much sense to have your start script call your build script: your app only needs to be compiled once.
Modify your start script so it doesn't call your build script:
"build": "rimraf ./build && tsc",
"start": "node build/index.js",
Heroku automatically runs your build script at deploy time, and now it won't try to re-compile it at runtime.

ts-node-dev: no script to run provided

My NodeJs project have an error message:
dev_api | yarn run v1.15.2
dev_api | warning package.json: No license field
dev_api | $ set debug=* && ts-node-dev --respawn --inspect --transpileOnly ./src/index.ts
dev_api | ts-node-dev: no script to run provided
dev_api | Usage: ts-node-dev [options] script [arguments]
dev_api |
dev_api | error Command failed with exit code 1.
dev_api | info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
My package.json:
{
"name": "API_CLIENT_BANK",
"version": "0.0.1",
"description": "Awesome project developed with TypeORM.",
"devDependencies": {
"#types/jest": "^24.0.20",
"#types/node": "^8.0.29",
"ts-jest": "^24.1.0",
"ts-node": "3.3.0",
"typescript": "3.3.3333"
},
"dependencies": {
"#sentry/node": "5.7.1",
"#types/bcryptjs": "^2.4.2",
"#types/body-parser": "^1.17.1",
"#types/cors": "^2.8.6",
"#types/helmet": "^0.0.44",
"#types/jsonwebtoken": "^8.3.5",
"#types/supertest": "^2.0.8",
"#types/swagger-jsdoc": "^3.0.2",
"bcryptjs": "^2.4.3",
"body-parser": "^1.19.0",
"class-transformer": "^0.2.3",
"class-validator": "^0.10.2",
"cors": "^2.8.5",
"dotenv": "^8.2.0",
"express": "^4.15.4",
"helmet": "^3.21.2",
"jest": "^24.9.0",
"jsonwebtoken": "^8.5.1",
"morgan": "^1.9.1",
"mysql": "^2.17.1",
"prettier": "^1.18.2",
"reflect-metadata": "^0.1.10",
"sqlite3": "^4.0.3",
"supertest": "^4.0.2",
"swagger-jsdoc": "^3.4.0",
"swagger-stats": "^0.95.11",
"swagger-ui-express": "^4.1.2",
"ts-node-dev": "^1.0.0-pre.43",
"tsc-watch": "^4.1.0",
"tslint": "^5.20.0",
"tslint-config-prettier": "^1.18.0",
"tslint-eslint-rules": "^5.4.0",
"tslint-plugin-prettier": "^2.0.1",
"typeorm": "0.2.20"
},
"scripts": {
"tsc": "tsc",
"start": "set debug=* && ts-node-dev --respawn --inspect --transpileOnly ./src/index.ts",
"prod": "tsc && node ./build/index.js",
"schema:drop": "ts-node ./node_modules/typeorm/cli.js schema:drop",
"schema:sync": "ts-node ./node_modules/typeorm/cli.js schema:sync",
"migration:run": "ts-node ./node_modules/typeorm/cli.js migration:run",
"test": "jest --maxWorkers=1 --verbose=true",
"migration:start": "yarn schema:drop && yarn schema:sync && yarn migration:run"
}
}
The error say ts-node-dev: no script to run provided, but I gave it:
set debug=* && ts-node-dev --respawn --inspect --transpileOnly ./src/index.ts
That no script to run provided error is the slightly unhelpful way that ts-node-dev's behaves if it doesn't recognize an option. (This is true as far as v1.1.6, at any rate.)
The problem here is that it doesn't understand the --transpileOnly option. Possibly older versions did, because you see a few examples around the web with that option. But now you need to write --transpile-only.
You'd think it would say something like "Unrecognized option: --transpileOnly", but no.
(The answer from Emefile Francis Waje does include this change, but it's easily missed, because it also proposes two more changes: making ts-node-dev a dev dependency, and using npx. So when I first read that answer, I totally missed the change from --transpileOnly to --transpile-only because I was focusing on the other two changes. So I'm calling this detail out here in a separate answer because it's the root cause of the error that the question mentions.)
Try to run
npm i ts-node-dev --save-dev,
and modify your script to
npx ts-node-dev --respawn --transpile-only --debug ./src/index.ts

node_modules/bcrypt: Command failed. node-pre-gyp: Permission denied

story
Last week I reinstalled my kubuntu, next to that I want to work on projects stored on another hard drive.
When I use Yarn Install I have the following error (see §log below).
Before reinstalling kubuntu everything was working fine.
spec
hadock in ~
➜ nvm -v
0.37.2
hadock in ~
➜ node -v
v15.8.0
hadock in ~
➜ npm -v
7.5.1
hadock in ~
➜ yarn -v
1.22.10
hadock in ~
➜ git --version
git version 2.27.0
my package.json
{
"name": "api",
"private": true,
"version": "1.0.0",
"scripts": {
"prebuild": "rimraf dist",
"build": "nest build",
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
"start": "nest start",
"dev": "NODE_ENV=development nest start --watch",
"dev:win": "SET NODE_ENV=development&& nest start --watch",
"start:debug": "nest start --debug --watch",
"start:prod": "node dist/src/main",
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\"",
"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",
"generate-data": "node scripts/generate-dev-data-index.js"
},
"dependencies": {
"#nestjs/common": "^7.4.4",
"#nestjs/core": "^7.4.4",
"#nestjs/jwt": "^7.1.0",
"#nestjs/mongoose": "^7.0.2",
"#nestjs/passport": "^7.1.0",
"#nestjs/platform-express": "^7.4.4",
"#nestjs/swagger": "^4.6.1",
"#nestjs/testing": "^7.4.4",
"#vonage/server-sdk": "^2.10.4",
"aws-sdk": "^2.790.0",
"bcrypt": "^5.0.0",
"body-parser": "^1.19.0",
"class-transformer": "^0.3.1",
"class-validator": "^0.12.2",
"dotenv": "^8.2.0",
"exifreader": "^3.12.6",
"express": "^4.17.1",
"faker": "^5.1.0",
"google-libphonenumber": "^3.2.15",
"jsonapi-serializer": "^3.6.6",
"jwt-decode": "^3.1.2",
"mongodb": "^3.6.2",
"mongoose": "^5.11.15",
"multer": "^1.4.2",
"nestjs-pino": "^1.2.0",
"passport": "^0.4.1",
"passport-jwt": "^4.0.0",
"passport-local": "^1.0.0",
"reflect-metadata": "^0.1.13",
"rimraf": "^3.0.2",
"rxjs": "^6.6.3",
"sharp": "^0.26.2",
"sib-api-v3-typescript": "^2.0.2",
"swagger-ui-express": "^4.1.4"
},
"devDependencies": {
"#nestjs/cli": "^7.5.1",
"#nestjs/schematics": "^7.1.2",
"#shelf/jest-mongodb": "^1.2.3",
"#types/aws-sdk": "^2.7.0",
"#types/bcrypt": "^3.0.0",
"#types/body-parser": "^1.19.0",
"#types/dotenv": "^8.2.0",
"#types/express": "^4.17.8",
"#types/faker": "^5.1.2",
"#types/google-libphonenumber": "^7.4.19",
"#types/jest": "^26.0.14",
"#types/jsonapi-serializer": "^3.6.3",
"#types/node": "^14.11.8",
"#types/passport": "^1.0.4",
"#types/passport-jwt": "^3.0.3",
"#types/sharp": "^0.26.1",
"#types/supertest": "^2.0.10",
"#typescript-eslint/eslint-plugin": "^4.4.0",
"#typescript-eslint/parser": "^4.4.0",
"eslint": "^7.11.0",
"eslint-config-airbnb-base": "^14.2.0",
"eslint-config-prettier": "^6.12.0",
"eslint-plugin-import": "^2.22.1",
"jest": "^26.5.3",
"jest-serial-runner": "^1.1.0",
"pino-pretty": "^4.3.0",
"prettier": "^2.1.2",
"supertest": "^5.0.0",
"ts-jest": "^26.4.1",
"ts-loader": "^8.0.4",
"ts-node": "^9.0.0",
"tsconfig-paths": "^3.9.0",
"typescript": "^4.0.3"
},
"jest": {
"displayName": {
"name": "API",
"color": "blue"
},
"verbose": true,
"runner": "jest-serial-runner",
"testSequencer": "../src/_test/config/sequencer.jest.js",
"setupFiles": [
"../src/_test/config/dotenv.module.ts"
],
"moduleFileExtensions": [
"js",
"json",
"ts"
],
"rootDir": "src",
"testRegex": ".spec.ts$",
"transform": {
"^.+\\.(t|j)s$": "ts-jest"
},
"collectCoverageFrom": [
"**/*.(t|j)s"
],
"coverageDirectory": "../coverage",
"testEnvironment": "node",
"preset": "#shelf/jest-mongodb",
"testTimeout": 30000
}
}
Log
[4/4] Building fresh packages...
⠁
[6/6] ⠂ mongodb-memory-server
[2/6] ⠂ bcrypt
[3/6] ⠂ exifreader
[4/6] ⠂ sharp
verbose 24.479452317
verbose 24.558439202 Error: /home/hadock/samus/Projects/rm/rm-api/node_modules/bcrypt: Command failed.
Exit code: 126
Command: node-pre-gyp install --fallback-to-build
Arguments:
Directory: /home/hadock/samus/Projects/rm/rm-api/node_modules/bcrypt
Output:
/bin/sh: 1: node-pre-gyp: Permission denied
at ProcessTermError.ExtendableBuiltin (/home/hadock/.nvm/versions/node/v15.8.0/lib/node_modules/yarn/lib/cli.js:721:66)
at ProcessTermError.MessageError (/home/hadock/.nvm/versions/node/v15.8.0/lib/node_modules/yarn/lib/cli.js:750:123)
at new ProcessTermError (/home/hadock/.nvm/versions/node/v15.8.0/lib/node_modules/yarn/lib/cli.js:790:113)
at ChildProcess.<anonymous> (/home/hadock/.nvm/versions/node/v15.8.0/lib/node_modules/yarn/lib/cli.js:25884:17)
at ChildProcess.emit (node:events:378:20)
at maybeClose (node:internal/child_process:1067:16)
at Socket.<anonymous> (node:internal/child_process:453:11)
at Socket.emit (node:events:378:20)
at Pipe.<anonymous> (node:net:665:12)
error /home/hadock/samus/Projects/rm/rm-api/node_modules/bcrypt: Command failed.
Exit code: 126
Command: node-pre-gyp install --fallback-to-build
Arguments:
my test
git clone the project, yarn -> doesn't work
uninstall bcrypt from the package & reinstall via yarn install bcrypt -> doesn't work
uninstall nvm & yarn & reinstall and yarn install -> doesn't work
i check my permission into the project file every file is set to my user drwxrwxr-x hadock hadock
i do npm install -g node-gyp & rm -rf node_modules & yarn fix the error but got a new one (opencollective: Permission denied)
[4/4] Building fresh packages...
[1/6] ⠂ #nestjs/core
[2/6] ⠂ bcrypt
[3/6] ⠂ exifreader
[4/6] ⠂ sharp
verbose 35.698648389 /bin/sh: 1: opencollective: Permission denied
verbose 35.744661021 Error: /home/hadock/samus/Projects/rm/rm-api/node_modules/bcrypt: Command failed.
Exit code: 126
Command: node-pre-gyp install --fallback-to-build
Arguments:
Directory: /home/hadock/samus/Projects/rm/rm-api/node_modules/bcrypt
Output:
/bin/sh: 1: node-pre-gyp: Permission denied
at ProcessTermError.ExtendableBuiltin (/home/hadock/.nvm/versions/node/v15.8.0/lib/node_modules/yarn/lib/cli.js:721:66)
at ProcessTermError.MessageError (/home/hadock/.nvm/versions/node/v15.8.0/lib/node_modules/yarn/lib/cli.js:750:123)
at new ProcessTermError (/home/hadock/.nvm/versions/node/v15.8.0/lib/node_modules/yarn/lib/cli.js:790:113)
at ChildProcess.<anonymous> (/home/hadock/.nvm/versions/node/v15.8.0/lib/node_modules/yarn/lib/cli.js:25884:17)
at ChildProcess.emit (node:events:378:20)
at maybeClose (node:internal/child_process:1067:16)
at Socket.<anonymous> (node:internal/child_process:453:11)
at Socket.emit (node:events:378:20)
at Pipe.<anonymous> (node:net:665:12)
error /home/hadock/samus/Projects/rm/rm-api/node_modules/bcrypt: Command failed.
Exit code: 126
Command: node-pre-gyp install --fallback-to-build
Arguments:
doesn't work or not relevant
Bcrypt fails to install
https://github.com/kelektiv/node.bcrypt.js/issues/803
https://github.com/kelektiv/node.bcrypt.js/issues/848
npm install bcrypt failed node
https://github.com/kelektiv/node.bcrypt.js/issues/590
https://github.com/kelektiv/node.bcrypt.js/issues/514
Edit 15 Feb 2021 - 1
I have clone the project in my os drive and everything works fine.
So I run chmod -R ug+rwx XXXX where XXXX is my project drive.
But the yarn install doesn't work.
I keep searching.
Edit 15 Feb 2021 - 2
The problem is a problem of right.
I had to change the way my second drive was mounted on boot in the fstab file (the mount option part) :
+ UUID="12345" /home/hadock/samus ext4 defaults 0 1
I had the same problem with one ubuntu image in one of my containers:
You can try sudo apt-get install build-essential on your computer or
apk add --no-cache --virtual .gyp \
python \
make \
g++ \
&& apk del .gyp
to be more specific (recommended for images)

npm dev:start does not run

I have the following scripts in my package.json
{
"name": "demo-api",
"version": "0.0.1",
"description": "",
"author": "",
"license": "MIT",
"scripts": {
"prebuild": "rimraf dist",
"build": "nest build",
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
"start": "NODE_ENV=development 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": "^6.10.14",
"#nestjs/core": "^6.10.14",
"#nestjs/graphql": "^6.6.1",
"#nestjs/jwt": "^6.1.2",
"#nestjs/mongoose": "^6.3.1",
"#nestjs/passport": "^6.2.0",
"#nestjs/platform-express": "^6.10.14",
"#types/graphql": "^14.5.0",
"apollo-server-express": "^2.10.1",
"class-transformer": "^0.2.3",
"dotenv": "^8.2.0",
"graphql": "^14.6.0",
"graphql-tools": "^4.0.7",
"mongoose": "^5.9.2",
"passport": "^0.4.1",
"passport-jwt": "^4.0.0",
"passport-local": "^1.0.0",
"reflect-metadata": "^0.1.13",
"rimraf": "^3.0.0",
"rxjs": "^6.5.4",
"type-graphql": "^0.17.6"
},
"devDependencies": {
"#nestjs/cli": "^6.13.2",
"#nestjs/schematics": "^6.8.1",
"#nestjs/testing": "^6.10.14",
"#types/express": "^4.17.2",
"#types/jest": "25.1.2",
"#types/mongoose": "^5.7.1",
"#types/node": "^13.1.6",
"#types/passport-jwt": "^3.0.3",
"#types/passport-local": "^1.0.33",
"#types/supertest": "^2.0.8",
"#typescript-eslint/eslint-plugin": "^2.12.0",
"#typescript-eslint/parser": "^2.12.0",
"eslint": "^6.7.2",
"eslint-config-prettier": "^6.7.0",
"eslint-plugin-import": "^2.19.1",
"jest": "^24.9.0",
"prettier": "^1.18.2",
"supertest": "^4.0.2",
"ts-jest": "25.2.0",
"ts-loader": "^6.2.1",
"ts-node": "^8.6.0",
"tsconfig-paths": "^3.9.0",
"typescript": "^3.8.2",
"typescript-tools": "^0.3.1"
},
"jest": {
"moduleFileExtensions": [
"js",
"json",
"ts"
],
"rootDir": "src",
"testRegex": ".spec.ts$",
"transform": {
"^.+\\.(t|j)s$": "ts-jest"
},
"coverageDirectory": "../coverage",
"testEnvironment": "node"
}
}
When I try to run npm start:dev am getting the following error:
git:(develop) npm start:dev
Usage: npm <command>
where <command> is one of:
access, adduser, audit, bin, bugs, c, cache, ci, cit,
clean-install, clean-install-test, completion, config,
create, ddp, dedupe, deprecate, dist-tag, docs, doctor,
edit, explore, fund, get, help, help-search, hook, i, init,
install, install-ci-test, install-test, it, link, list, ln,
login, logout, ls, org, outdated, owner, pack, ping, prefix,
profile, prune, publish, rb, rebuild, repo, restart, root,
run, run-script, s, se, search, set, shrinkwrap, star,
stars, start, stop, t, team, test, token, tst, un,
uninstall, unpublish, unstar, up, update, v, version, view,
whoami
npm <command> -h quick help on <command>
npm -l display full usage info
npm help <term> search for help on <term>
npm help npm involved overview
Specify configs in the ini-formatted file:
/Users/harshamv/.npmrc
or on the command line via: npm <command> --key value
Config info can be viewed via: npm help config
npm#6.13.7 /usr/local/lib/node_modules/npm
Did you mean this?
start
Please use the following command whenever creating a custom scripts in
npm run custom-script
Eg: npm run start:dev
Hope it helps
You should follow some steps. When I was stuck in this problem.
if you are using node js and React :
step 1: you should write a script in package.json script
-----> "dev": " node --watch node js file (app.mjs)"
Step 2: you should now go to your react file directory and then
-----> run the command: npm run start dev
it will automatically run your react file when you edit something in the project

Gulp failed after push

So I did this tutorial,(The basic Azure Cosmos DB (MongoDB) with Node.js)
https://learn.microsoft.com/en-us/azure/app-service-web/app-service-web-tutorial-nodejs-mongodb-app
I didn't changed anything in the code just what tutorial says and after
git push azure master I get
gulp failed(link to image)
Does anyone have any clues from what comes this error?
Edit: deploy.sh Gulp part
if [ -e "$DEPLOYMENT_TARGET/gulpfile.js" ]; then
cd "$DEPLOYMENT_TARGET"
eval ./node_modules/.bin/gulp imagemin
eval ./node_modules/.bin/gulp prod <----I added this line and still fails
exitWithMessageOnError "gulp failed"
cd - > /dev/null
fi
package.json only Gulp part
{
"name": "meanjs",
"description": "Full-Stack JavaScript with MongoDB, Express, AngularJS, and Node.js.",
"version": "0.5.0",
"meanjs-version": "0.5.0",
"private": false,
"author": "https://github.com/meanjs/mean/graphs/contributors",
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/meanjs/mean.git"
},
"engines": {
"node": "6.9.1",
"npm": "3.10.8"
},
"scripts": {
"update": "npm update && npm prune && npm run bower",
"clean": "rm -rf node_modules/ public/lib/",
"reinstall": "npm cache clean && npm run clean && npm install",
"start": "gulp",
"start:prod": "gulp prod",
"start:debug": "node-debug --web-host 0.0.0.0 server.js & gulp debug",
"gulp": "gulp",
"bower": "bower install --allow-root && bower prune --allow-root",
"lint": "gulp lint",
"test": "gulp test",
"test:server": "gulp test:server",
"test:server:watch": "gulp test:server:watch",
"test:client": "gulp test:client",
"test:e2e": "gulp test:e2e",
"test:coverage": "gulp test:coverage",
"postinstall": "npm run bower",
"generate-ssl-certs": "scripts/generate-ssl-certs.sh"
},
"dependencies": {
"passport-google-oauth": "~1.0.0",
"passport-linkedin": "~1.0.0",
"passport-local": "~1.0.0",
"passport-paypal-openidconnect": "~0.1.1",
"passport-twitter": "~1.0.4",
"serve-favicon": "~2.4.2",
"socket.io": "^2.0.2",
"validator": "~7.0.0",
"winston": "^2.3.1",
"wiredep": "~4.0.0"
},
"devDependencies": {
"gulp": "^3.9.1",
"gulp-angular-templatecache": "~2.0.0",
"gulp-autoprefixer": "~3.1.0",
"gulp-concat": "~2.6.0",
"gulp-csslint": "~1.0.0",
"gulp-csso": "~3.0.0",
"gulp-eslint": "~3.0.1",
"gulp-imagemin": "~3.2.0",
"gulp-istanbul": "~1.1.1",
"gulp-less": "~3.3.0",
"gulp-load-plugins": "~1.5.0",
"gulp-mocha": "~3.0.1",
"gulp-ng-annotate": "~2.0.0",
"gulp-nodemon": "~2.2.1",
"gulp-protractor": "^4.0.0",
"gulp-refresh": "~1.1.0",
"gulp-rename": "~1.2.2",
"gulp-rev": "^7.1.2",
"gulp-sass": "~3.1.0",
"gulp-uglify": "~2.1.2",
"gulp-util": "~3.0.7",
}
}
I also get this error on the begin of the push logs
remote: glob error { Error: ENOTSUP: operation not supported on socket, scandir 'D:\home\site\wwwroot\node_modules\phant
omjs-prebuilt\node_modules\request\node_modules\http-signature\node_modules\sshpk\bin\sshpk-conv'
remote: at Error (native)
Edit2: The error changed a bit
remote: An error has occurred during web site deployment.
remote: throw err;
remote: gulp failed
remote: ^
remote: Error: Cannot find module 'readable-stream/transform'
You did install gulp. Make sure you have installed gulp-cli.
And, as mentioned in "no command 'gulp' found - after installation"
Also, node_modules/.bin/ isn't in your %PATH%.
But it is automatically added by npm when running npm scripts (see this blog post for reference).

Resources