Why npm run dev giving error even all dependencies are installed? - node.js

Problem:
Trying npm run dev to start the server but it's giving following error although exactly same code is working fine for other team members.
Error:
Error: Cannot find module 'braintree'
Require stack:
- C:\Users\Zainulabideen\Documents\GitHub\wine\dist\routes\api\braintree\clientToken.js
- C:\Users\Zainulabideen\Documents\GitHub\wine\dist\app.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:982:15)
at Function.Module._load (internal/modules/cjs/loader.js:864:27)
at Module.require (internal/modules/cjs/loader.js:1044:19)
at require (internal/modules/cjs/helpers.js:77:18)
at Object.<anonymous> (C:\Users\Zainulabideen\Documents\GitHub\wine\dist\routes\api\braintree\clientToken.js:5:17)
at Module._compile (internal/modules/cjs/loader.js:1158:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1178:10)
at Module.load (internal/modules/cjs/loader.js:1002:32)
at Function.Module._load (internal/modules/cjs/loader.js:901:14)
at Module.require (internal/modules/cjs/loader.js:1044:19) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'C:\\Users\\Zainulabideen\\Documents\\GitHub\\wine\\dist\\routes\\api\\braintree\\clientToken.js',
'C:\\Users\\Zainulabideen\\Documents\\GitHub\\wine\\dist\\app.js'
]
}
[nodemon] app crashed - waiting for file changes before starting...
Relevant Code:
app.js
....
const brainTreeToken = require("./routes/api/braintree/clientToken");
app.get("/client_token", function (req, res) {
brainTreeToken.braintreeClient(req, res);
});
....
clientToken.js
var braintree = require("braintree");
import { useDispatch } from "react-redux";
const braintreeClient = (req, res) => {
var gateway = braintree.connect({
environment: braintree.Environment.Sandbox,
merchantId: "XXXXXXXXXXX",
publicKey: "XXXXXXXXXXXX",
privateKey: "XXXXXXXXXXX",
});
gateway.clientToken.generate({}, function(err, response) {
var clientToken = response.clientToken;
res.send(clientToken);
});
};
module.exports = {
braintreeClient: braintreeClient,
};
Package.json
{
"name": "XYZ",
"version": "0.0.10",
"private": true,
"description": "React APP",
"license": "ISC",
"author": "Temp",
"main": "index.js",
"scripts": {
"start": "node dist/app.js",
"start:prod": "npm i --production && npm run build && npm run server",
"dev": "echo Running App Under Watcher Nodemon Hot Deploy && nodemon dist/app.js",
"test": "jest --bail",
"test:watch": "jest --watch",
"build": "sh ./scripts/build-app.sh",
"build:dev": "SET NODE_ENV=development && npm run build",
"build:prod": "SET NODE_ENV=production npm run build",
"server": "node dist/app.js",
"server:dev": "SET NODE_ENV=development npm run server",
"server:prod": "SET NODE_ENV=production npm run server",
"docker": "sh ./scripts/build-docker.sh",
"webpack": "rimraf ./build && webpack --config tools/webpack.config.js",
"lint": "eslint src/**/*.js",
"hotstart": "nohup node src/server.js > nohup.out 2> nohup.err < /dev/null & react-scripts start"
},
"eslintConfig": {
"extends": "react-app"
},
"dependencies": {
"awesome-notifications": "^3.0.3",
"babel-eslint": "^10.0.2",
"body-parser": "^1.19.0",
"bootstrap": "^4.3.1",
"console-stamp": "^0.2.9",
"cookie-parser": "~1.4.3",
"cors": "^2.8.5",
"debug": "~2.6.9",
"eslint": "^6.0.1",
"eslint-config-react-app": "^4.0.1",
"eslint-loader": "^2.2.1",
"eslint-plugin-flowtype": "^3.11.1",
"eslint-plugin-import": "^2.18.0",
"eslint-plugin-jsx-a11y": "^6.2.3",
"eslint-plugin-react": "^7.14.2",
"express": "^4.17.1",
"express-session": "^1.16.2",
"fbemitter": "^2.1.1",
"font-awesome": "^4.7.0",
"http-errors": "~1.6.2",
"i18next": "^19.0.1",
"i18next-browser-languagedetector": "^4.0.1",
"i18next-xhr-backend": "^3.2.2",
"moment": "^2.24.0",
"morgan": "^1.9.1",
"nodemon": "^1.19.1",
"path": "^0.12.7",
"pem": "^1.14.2",
"prop-types": "^15.7.2",
"proxy": "^1.0.1",
"react": "^16.12.0",
"react-bootstrap": "^1.0.0-beta.12",
"react-datepicker": "^2.9.6",
"react-dev-utils": "^9.0.1",
"react-dom": "^16.12.0",
"react-flexbox-grid": "^2.1.2",
"react-hooks-paginator": "^0.4.0",
"react-i18next": "^9.0.10",
"react-iframe": "^1.8.0",
"react-js-pagination": "^3.0.2",
"react-notifications-component": "^2.0.7",
"react-redux": "^7.1.1",
"react-router": "^5.0.1",
"react-router-dom": "^5.0.1",
"react-router-redux": "^4.0.8",
"react-scripts": "^3.3.1",
"react-select": "^3.0.8",
"react-spinners": "^0.6.1",
"react-switch": "^5.0.1",
"react-table": "^6.10.0",
"react-toastify": "^5.4.1",
"reactstrap": "^8.4.0",
"redux": "^4.0.4",
"redux-saga": "^1.1.1",
"request": "^2.88.2",
"simple-react-validator": "^1.2.2",
"socket.io": "^2.2.0",
"underscore": "^1.9.2"
},
"devDependencies": {
"babel-cli": "^6.26.0",
"babel-core": "^6.26.3",
"babel-loader": "^7.1.5",
"babel-plugin-transform-class-properties": "^6.24.1",
"babel-plugin-transform-object-rest-spread": "^6.26.0",
"babel-plugin-transform-runtime": "^6.23.0",
"babel-preset-env": "^1.7.0",
"babel-preset-es2015": "^6.24.1",
"babel-preset-react": "^6.24.1",
"babel-preset-stage-0": "^6.24.1",
"braintree-web": "^3.58.0",
"css-loader": "^3.2.0",
"eslint": "^6.5.0",
"eslint-config-prettier": "^6.3.0",
"eslint-config-react-app": "^4.0.1",
"eslint-loader": "^2.2.1",
"eslint-plugin-flowtype": "^3.11.1",
"eslint-plugin-import": "^2.18.2",
"eslint-plugin-jsx-a11y": "^6.2.3",
"eslint-plugin-prettier": "^3.1.0",
"eslint-plugin-react": "^7.14.3",
"eslint-plugin-react-hooks": "^1.7.0",
"extract-text-webpack-plugin": "^3.0.2",
"file-loader": "^4.3.0",
"html-webpack-plugin": "^3.2.0",
"jest": "^24.8.0",
"mini-css-extract-plugin": "^0.7.0",
"node-sass": "^4.13.1",
"paypal-checkout": "^4.0.311",
"prettier": "^1.18.2",
"puppeteer": "^1.17.0",
"rimraf": "^2.7.1",
"sass-loader": "^7.1.0",
"url-loader": "^2.0.0",
"webpack": "^4.34.0",
"webpack-cli": "^3.3.6",
"webpack-dev-server": "^3.7.1"
},
"nodemonConfig": {
"ext": "js, html, scss",
"ignore": [
"node_modules/*",
"build/*",
"dist/*",
"scripts/*",
".git"
],
"exec": "sh ./scripts/build-watch.sh"
}
}
Operating System and Terminal:
Windows 10, git bash
Approaches tried:
1) npm install
2) npm install --save-dev
3) Deleted node_modules folder again tried npm install
4) Deleted package-lock.json, node_modules folder and again tried npm install
5) Checked if particular is present in node_modules, it's present.
6) Using git-bash terminal, tried switching to cygwin terminal.
7) As using Windows, tried restarting machine. (Pardon, if it hurted you :( )
8) Verified folder structure, it's fine.
Note:
Codebase was working fine for before talking pull, after pull it's creating problem but it's working completely fine for other team members even after pull.

I don't see braintree in package.json, it is working in your team member's pc because they maybe installed it separately. Sometimes I tend to forget adding it to package.json when I develop a feature because it takes experimenting with bunch of packages so the package is in my node_modules folder already. Also there is a possibility that someone forgot to git add the package.json.
Anyway, To add to your package.json do and push,
npm i braintree --save
and push it after git add package.json

Related

Vuejs Module not found: Error: Can't resolve '../dist/helpers.esm' in node_modules/chart.js/helpers

I am trying to run npm run dev on one of my projects and getting **Module not found: Error: Can't resolve '../dist/helpers.esm' in node_modules/chart.js/helpers
You can see here => https://i.stack.imgur.com/wZc3o.png
Package.json
{
"private": true,
"scripts": {
"dev": "npm run development",
"development": "mix",
"watch": "mix watch",
"watch-poll": "mix watch -- --watch-options-poll=1000",
"hot": "mix watch --hot",
"prod": "npm run production",
"production": "mix --production",
"serve": "php artisan serve",
"clear-cache": "php artisan optimize:clear && composer dump-autoload && composer cc && npm cache clean --force"
},
"devDependencies": {
"axios": "^0.21.1",
"bootstrap": "^4.0.0",
"cross-env": "^5.2.1",
"jquery": "^3.2",
"laravel-mix": "^6.0.43",
"lodash": "^4.17.5",
"popper.js": "^1.12",
"resolve-url-loader": "^5.0.0",
"sass-loader": "^12.6.0",
"vue": "^2.5.7",
"vue-loader": "^15.9.8"
},
"dependencies": {
"chart.js": "^3.8.0",
"chartjs-plugin-datalabels": "^2.0.0",
"css-percentage-circle": "^2.0.1",
"echarts": "^5.3.2",
"jspdf": "^2.3.1",
"jspdf-autotable": "^3.5.15",
"laravel-echo": "^1.11.7",
"moment": "^2.29.1",
"moment-timezone": "^0.5.32",
"node-sass": "^7.0.1",
"npm": "^8.6.0",
"pdf-lib": "^1.17.1",
"percircle": "^1.0.28",
"percircle-vue": "^0.1.2",
"pusher-js": "^7.1.0-beta",
"tinymce": "^5.7.1",
"v-charts": "^1.17.10",
"v-skeletor": "^0.0.4",
"v-slim-dialog": "0.0.10",
"vue-axios": "^2.1.4",
"vue-chartjs": "^4.0.0",
"vue-codemirror": "^4.0.6",
"vue-confirm-dialog": "^1.0.2",
"vue-css-percentage-circle": "^2.0.0",
"vue-js-modal": "^2.0.1",
"vue-month-picker": "^1.5.0",
"vue-multiselect": "^2.1.6",
"vue-router": "^3.4.9",
"vue-step-progress": "^0.3.7",
"vue-tinymce-editor": "^1.6.2",
"vue-toast-notification": "^0.6.2",
"vue2-daterange-picker": "^0.6.8",
"vuedraggable": "^2.24.3",
"vuejs-datepicker": "^1.6.2",
"vuejs-dialog": "^1.4.2",
"vuex-persistedstate": "^3.0.0",
"yan-progress": "^1.0.3"
}
}
Node version install on my system is 18.0.0 and npm is 8.6.0
It was working just fine but now its not

how to run multiple watch script in docker

I'am moving my react apps into docker, I am working in legacy project and we have multiple react apps. We are attaching script with react apps in script tags on every page whose need to use this files. For docker we want to use Express to serve our files.
Is there any way to run multiple watch commands ?
here is my package.json file:
{
"name": "docker apps",
"version": "3.0.0",
"description": "apps",
"license": "ISC",
"author": "devs",
"main": "main.js",
"engines": {
"node": ">=14.7.0",
"npm": ">=6.14.13"
},
"scripts": {
"requirements-check": "node checkNodeVersion.js",
"react": "webpack --env.mode production --env.app react",
"react-watch": "webpack --env.mode development --env.app react --watch",
"serve": "nodemon server.js",
"serve:prod": "node server.js --port=80",
"build": "npm run react",
"start": "npm run react-watch",
"test": "jest",
"lint": "eslint .",
"dev-start": "concurrently \"npm run react-watch\" \"npm run serve\"",
"dev-build": "concurrently \"npm run build\" \"npm run serve:prod\"",
"lint-payment": "eslint payment/",
"lint-formLibrary": "eslint formLibrary/",
"lint-fileManager": "eslint fileManager/",
"lint-blockLibrary": "eslint LPBlockLibrary/",
"lint-contracts": "eslint contracts/",
"lint-payment:fix": "eslint --fix payment/",
"lint-formLibrary:fix": "eslint --fix formLibrary/",
"lint-fileManager:fix": "eslint --fix fileManager/",
"lint-blockLibrary:fix": "eslint --fix LPBlockLibrary/",
"lint-contracts:fix": "eslint --fix contracts/",
"lint:fix": "eslint --fix ."
},
"dependencies": {
"#mikecousins/react-pdf": "^5.5.1",
"#tkaramanski/fmcomponents": "^1.6.2",
"#types/testing-library__jest-dom": "^5.9.5",
"axios": "^0.21.1",
"bootstrap": "^4.1.3",
"classnames": "^2.2.6",
"cors": "^2.8.5",
"express": "^4.17.1",
"gulp-cli": "^2.2.0",
"gulp-install": "^1.1.0",
"handlebars-loader": "^1.7.1",
"jsdom": "^16.6.0",
"lodash": "^4.17.11",
"postcss": "^8.1.4",
"postcss-js": "^3.0.1",
"prop-types": "^15.7.2",
"react": "^16.9.0",
"react-bs-notifier": "^5.0.0",
"react-datepicker": "^4.1.1",
"react-dnd": "^7.3.2",
"react-dnd-html5-backend": "^7.2.0",
"react-dom": "^16.9.0",
"react-dropzone": "^7.0.1",
"react-hook-form": "^4.9.6",
"react-hot-loader": "^4.12.18",
"react-infinite-scroll-component": "^4.2.0",
"react-jss": "^8.6.1",
"react-popper-tooltip": "^4.3.1",
"react-redux": "^7.1.3",
"react-router-dom": "^5.2.0",
"react-scrollbar": "^0.5.4",
"reactstrap": "^6.5.0",
"redux": "^4.0.4",
"redux-devtools-extension": "^2.13.8",
"redux-persist": "^6.0.0",
"redux-thunk": "^2.3.0",
"reselect": "^4.0.0",
"resolve-url-loader": "^3.1.2",
"semver": "^5.7.1",
"styled-components": "^5.3.0",
"typesafe-actions": "^5.1.0"
},
"devDependencies": {
"#babel/core": "^7.13.14",
"#babel/plugin-proposal-class-properties": "^7.13.0",
"#babel/plugin-proposal-optional-chaining": "^7.13.12",
"#babel/plugin-transform-runtime": "^7.13.10",
"#babel/preset-env": "^7.13.12",
"#babel/preset-react": "^7.13.13",
"#babel/preset-stage-0": "^7.8.3",
"#babel/preset-typescript": "^7.13.0",
"#testing-library/jest-dom": "^5.14.1",
"#testing-library/react": "^11.2.5",
"#tkaramanski/fmcomponents": "^1.5.1",
"#types/jest": "^26.0.22",
"#types/react": "^17.0.3",
"#types/react-datepicker": "^4.1.4",
"#types/react-dom": "^17.0.2",
"#types/react-lazyload": "^3.1.0",
"#types/react-redux": "^7.1.16",
"#types/react-router-dom": "^5.1.8",
"#types/styled-components": "^5.1.7",
"#typescript-eslint/eslint-plugin": "^4.17.0",
"autoprefixer": "^9.8.0",
"babel-eslint": "^10.1.0",
"babel-jest": "^26.6.3",
"babel-loader": "^8.2.2",
"babel-plugin-macros": "^3.0.1",
"babel-plugin-styled-components": "^1.12.0",
"babel-polyfill": "^6.26.0",
"babel-preset-es2015": "^6.24.1",
"babel-preset-react": "^6.24.1",
"clean-webpack-plugin": "^3.0.0",
"concurrently": "^5.2.0",
"copy-webpack-plugin": "^6.0.1",
"css-loader": "^3.6.0",
"enzyme": "^3.11.0",
"enzyme-adapter-react-16": "^1.15.4",
"eslint": "^7.10.0",
"eslint-config-airbnb": "^18.2.1",
"eslint-config-airbnb-typescript": "^12.3.1",
"eslint-plugin-import": "^2.23.4",
"eslint-plugin-jsx-a11y": "^6.3.1",
"eslint-plugin-react": "^7.21.3",
"eslint-plugin-react-hooks": "^4.2.0",
"extract-loader": "^5.1.0",
"file-loader": "^6.0.0",
"gulp": "^4.0.2",
"gulp-babel": "^8.0.0",
"gulp-cli": "^2.2.0",
"gulp-concat": "^2.6.1",
"gulp-sourcemaps": "^2.6.5",
"gulp-uglify": "^3.0.2",
"husky": "^4.3.0",
"identity-obj-proxy": "^3.0.0",
"jest": "^26.6.3",
"mini-css-extract-plugin": "^0.9.0",
"moment": "^2.26.0",
"postcss-loader": "^3.0.0",
"prettier": "^2.4.1",
"pump": "^3.0.0",
"react-copy-to-clipboard": "^5.0.2",
"react-test-renderer": "^16.13.1",
"react-tippy": "^1.4.0",
"redux-mock-store": "^1.5.4",
"renamer": "^1.1.4",
"sass": "^1.35.1",
"sass-loader": "^8.0.2",
"style-loader": "^1.2.1",
"ts-jest": "^26.5.4",
"ts-loader": "^8.1.0",
"typescript": "4.2.3",
"url-loader": "^4.1.0",
"webpack": "^4.43.0",
"webpack-cli": "^3.3.11",
"webpack-fix-style-only-entries": "^0.5.0",
"webpack-merge": "^4.2.2",
"wildcards-entry-webpack-plugin": "^2.1.0"
},
"husky": {
"hooks": {
"pre-commit": "npm run requirements-check",
"pre-push": "npm run lint"
}
},
"jest": {
"setupTestFrameworkScriptFile": "./setupTests.js",
"setupFiles": [
"./payment/src/__mocks__/data.js"
],
"collectCoverageFrom": [
"payment/src/__tests__/*.{js,jsx}",
"LPBlockLibrary/src/__testes__/*{ts,tsx}"
],
"moduleNameMapper": {
"\\.(png|jpg|gif|ttf|eot|svg)$": "<rootDir>/config/jest/fileMock.js"
},
"transform": {
"\\.tsx?$": "ts-jest",
"\\.jsx?$": "babel-jest"
}
}
}
here is my docker:
FROM node:14.17.0
WORKDIR /frontend-apps
ENV PATH /frontend-apps/node_modules/.bin:$PATH
COPY package.json \
package-lock.json \
.npmrc ./
RUN npm config set strict-ssl false
RUN npm install
RUN npm config set strict-ssl true
COPY . ./
EXPOSE 80
CMD [ "npm", "run", "dev-start"]
here is my docker-compose file.
version: '3.7'
services:
frontend-docker-app:
container_name: docker-front-apps
build:
context: .
dockerfile: Dockerfile.test
volumes:
- '.:/frontendApps'
- '/frontendApps/node_modules'
ports:
- 3000:3000
in docker file I try to run multiple commands with concurrently
"react-watch": "webpack --env.mode development --env.app react --watch",
"serve": "nodemon server.js",
"dev-start": "concurrently \"npm run react-watch\" \"npm run serve\"",
I solved my problem, it turned out that I accidentally remove my nodemon package from package.json, and I had bad docker compose config. I changed it to this version:
version: '3.7'
services:
frontend-docker-app:
container_name: docker-front-apps
working_dir: /var/www/app
build:
context: .
dockerfile: Dockerfile.test
volumes:
- .:/var/www/app
- '/frontendApps/node_modules'
tty: true
ports:
- 3000:3000
environment:
- CHOKIDAR_USEPOLLING=true
and changed cmd command from Docker file to this:
EXPOSE 80
CMD [ "npm", "run", "dev-build"]
and everything works fine.

Electron Error ENOENT: no such file or directory, open 'electron' After update from 9 to 10

Recently I update electron version from 9 to 10 and after updated getting this error on debug mode only
when I downgrade to 9 it's working correctly
Deleted Node_Module and package.lock file multiple times and reinstall all package but no luck
I tried to upgrade to 11 electrons also but facing the same issue
When I am running in production mode "Yarn Start" is working fine
The issue in dev mode only "Yarn dev"
ERROR:-
App threw an error during load Error: ENOENT: no such file or directory, open 'electron'
at Object.openSync (fs.js:462:3)
at Object.func [as openSync] (electron/js2c/asar.js:140:31)
at Object.readFileSync (fs.js:364:35)
at Object.fs.readFileSync (electron/js2c/asar.js:542:40)
at Module._extensions..js (internal/modules/cjs/loader.js:1165:22)
at Object.newLoader [as .js] (C:\SVN\mangocrossplatform\trunk\node_modules\pirates\lib\index.js:104:7)
at Module.load (internal/modules/cjs/loader.js:981:32)
at Module._load (internal/modules/cjs/loader.js:881:14)
at Function.Module._load (electron/js2c/asar.js:779:28)
at Module.require (internal/modules/cjs/loader.js:1023:19)
My Package.json File
{
"name": "mangoapps-messenger",
"productName": "Apps Messenger",
"version": "15.0.11",
"description": "Apps Messenger - An Universal Messenger For Apps",
"homepage": "",
"author": {
"email": "",
"name": ""
},
"scripts": {
"build": "yarn clean && concurrently \"yarn build-main\" \"yarn build-renderer\"",
"build-dll": "cross-env NODE_ENV=development webpack --config ./configs/webpack.config.renderer.dev.dll.babel.js --colors",
"build-main": "cross-env NODE_ENV=production webpack --config ./configs/webpack.config.main.prod.babel.js --colors",
"build-renderer": "cross-env NODE_ENV=production webpack --config ./configs/webpack.config.renderer.prod.babel.js --colors",
"dev": "yarn clean && cross-env START_HOT=1 node -r #babel/register ./internals/scripts/CheckPortInUse.js && cross-env START_HOT=1 yarn start-renderer-dev",
"package": "yarn build && electron-builder build --publish never",
"package-linux": "yarn build && electron-builder build --linux",
"package-mac": "yarn build && CSC_LINK=./certs/mac.p12 && CSC_IDENTITY_AUTO_DISCOVER=false && electron-builder build --mac",
"package-win": "yarn build && electron-builder build --win --x64",
"package-win32": "yarn build && electron-builder build --win --ia32",
"postinstall": "electron-builder install-app-deps && yarn build-dll && opencollective-postinstall",
"preinstall": "node ./internals/scripts/CheckYarn.js",
"prestart": "yarn build",
"start": "cross-env NODE_ENV=production electron ./dist/main.prod.js",
"start-main-dev": "cross-env HOT=1 NODE_ENV=development electron -r #babel/register ./app/main.dev.js",
"start-renderer-dev": "cross-env NODE_ENV=development webpack-dev-server --config configs/webpack.config.renderer.dev.babel.js",
"clean": "rimraf dist/"
},
"main": "./dist/main.prod.js",
"build": {
"productName": "Apps Messenger",
"appId": "com.mangoapps.electrondesktop",
"artifactName": "${name}-${version}.${ext}",
"generateUpdatesFilesForAllChannels": true,
"mac": {
"category": "productivity",
"type": "distribution",
"provisioningProfile": "certs/mac.provisionprofile",
"identity": "sdasdB",
"hardenedRuntime": true,
"entitlements": "build/entitlements.mac.inherit.plist",
"entitlementsInherit": "build/entitlements.mac.inherit.plist",
"gatekeeperAssess": false,
"extendInfo": {
"NSAppTransportSecurity": {
"NSAllowsArbitraryLoads": true,
"NSMicrophoneUsageDescription": "This lets you share using audio using the microphone.",
"NSCameraUsageDescription": "This lets you share a photo or video taken from your camera.",
"NSContactsUsageDescription": "This lets you enable access to your contacts and uses them to invite."
}
},
"target": [
"zip"
]
},
"linux": {
"target": [
"deb"
],
"category": "Productivity"
},
"win": {
"target": [
"nsis",
"msi"
],
"certificateFile": "",
"certificatePassword": "",
"publisherName": "",
"requestedExecutionLevel": "asInvoker",
"signAndEditExecutable": true,
"signDlls": true
},
"nsis": {
"oneClick": true,
"perMachine": false,
"deleteAppDataOnUninstall": true
},
"msi": {
"oneClick": true,
"perMachine": true
},
"files": [
"resources",
"dist/",
"dist/main.prod.js",
"dist/main.prod.js.map",
"package.json"
],
"directories": {
"buildResources": "resources",
"output": "release"
}
},
"keywords": [
"mangoapps",
"messenger"
],
"devDependencies": {
"#babel/core": "^7.4.0",
"#babel/plugin-proposal-class-properties": "^7.4.0",
"#babel/plugin-proposal-decorators": "^7.4.0",
"#babel/plugin-proposal-do-expressions": "^7.2.0",
"#babel/plugin-proposal-export-default-from": "^7.2.0",
"#babel/plugin-proposal-export-namespace-from": "^7.2.0",
"#babel/plugin-proposal-function-bind": "^7.2.0",
"#babel/plugin-proposal-function-sent": "^7.2.0",
"#babel/plugin-proposal-json-strings": "^7.2.0",
"#babel/plugin-proposal-logical-assignment-operators": "^7.2.0",
"#babel/plugin-proposal-nullish-coalescing-operator": "^7.2.0",
"#babel/plugin-proposal-numeric-separator": "^7.2.0",
"#babel/plugin-proposal-optional-chaining": "^7.2.0",
"#babel/plugin-proposal-pipeline-operator": "^7.3.2",
"#babel/plugin-proposal-throw-expressions": "^7.2.0",
"#babel/plugin-syntax-dynamic-import": "^7.2.0",
"#babel/plugin-syntax-import-meta": "^7.2.0",
"#babel/plugin-transform-react-constant-elements": "^7.2.0",
"#babel/plugin-transform-react-inline-elements": "^7.2.0",
"#babel/preset-env": "^7.4.2",
"#babel/preset-flow": "^7.0.0",
"#babel/preset-react": "^7.0.0",
"#babel/register": "^7.4.0",
"#fortawesome/fontawesome-pro": "^5.12.0",
"babel-core": "7.0.0-bridge.0",
"babel-jest": "^24.5.0",
"babel-loader": "^8.0.5",
"babel-plugin-dev-expression": "^0.2.1",
"babel-plugin-transform-react-remove-prop-types": "^0.4.24",
"babel-register": "^6.26.0",
"chalk": "^2.4.2",
"concurrently": "^4.1.0",
"cross-env": "^5.2.0",
"cross-spawn": "^6.0.5",
"css-loader": "2.1.1",
"detect-port": "^1.3.0",
"electron": "^10.0.0",
"electron-builder": "^22.9.1",
"enzyme": "^3.9.0",
"enzyme-adapter-react-16": "^1.11.2",
"enzyme-to-json": "^3.3.5",
"fbjs-scripts": "^1.2.0",
"file-loader": "^4.2.0",
"html-webpack-plugin": "^3.2.0",
"identity-obj-proxy": "^3.0.0",
"jest": "^24.5.0",
"mini-css-extract-plugin": "^0.8.0",
"node-sass": "^4.13.0",
"opencollective-postinstall": "^2.0.2",
"optimize-css-assets-webpack-plugin": "^5.0.1",
"prettier": "^1.16.4",
"react-svg-loader": "^3.0.3",
"react-test-renderer": "^16.8.6",
"redux-logger": "^3.0.6",
"rimraf": "^3.0.0",
"sass-loader": "^7.1.0",
"sinon": "^7.3.1",
"spectron": "^5.0.0",
"style-loader": "^0.23.1",
"terser-webpack-plugin": "^1.2.3",
"testcafe": "^1.1.0",
"testcafe-browser-provider-electron": "^0.0.8",
"testcafe-live": "^0.1.4",
"testcafe-react-selectors": "^3.1.0",
"url-loader": "^1.1.2",
"webpack": "^4.29.6",
"webpack-bundle-analyzer": "^3.1.0",
"webpack-cli": "^3.3.0",
"webpack-dev-server": "^3.2.1",
"webpack-merge": "^4.2.1",
"yarn": "^1.16.0"
},
"dependencies": {
"#babel/polyfill": "^7.7.0",
"#fortawesome/fontawesome-svg-core": "^1.2.26",
"#fortawesome/free-solid-svg-icons": "^5.12.0",
"#fortawesome/pro-duotone-svg-icons": "^5.12.0",
"#fortawesome/pro-light-svg-icons": "^5.12.0",
"#fortawesome/pro-regular-svg-icons": "^5.12.0",
"#fortawesome/pro-solid-svg-icons": "^5.12.0",
"#fortawesome/react-fontawesome": "^0.1.8",
"#trodi/electron-splashscreen": "^0.3.4",
"app-root-path": "^2.2.1",
"axios": "^0.21.1",
"babel-runtime": "^6.26.0",
"bootstrap": "^4.3.1",
"check-internet-connected": "^2.0.4",
"connected-react-router": "^6.3.2",
"copy-webpack-plugin": "^5.1.1",
"core-js": "2",
"custom-electron-titlebar": "^3.2.2-hotfix62",
"devtron": "^1.4.0",
"dotenv": "^8.2.0",
"electron-debug": "^2.1.0",
"electron-dl": "^3.0.2",
"electron-fetch": "^1.3.0",
"electron-localshortcut": "^3.1.0",
"electron-log": "^4.1.1",
"electron-positioner": "^4.1.0",
"electron-splashscreen": "^0.1.7",
"electron-store": "^3.2.0",
"electron-unhandled": "^3.0.2",
"electron-util": "^0.14.1",
"electron-window-state": "^5.0.3",
"emoji-mart": "^2.11.1",
"form-data": "^2.3.3",
"fs-extra": "^8.1.0",
"jquery": "^3.3.1",
"js-md5": "^0.7.3",
"lodash": "^4.17.15",
"mime-types": "^2.1.27",
"moment-timezone": "^0.5.27",
"node-mac-notifier": "file:local_dep/node-mac-notifier",
"node-machine-id": "^1.1.12",
"node-notifier": "^8.0.0",
"platform-folders": "^0.4.1",
"plist": "^3.0.1",
"popper.js": "^1.15.0",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"react-hot-loader": "^4.12.15",
"react-image-crop": "^8.4.0",
"react-lazyload": "^2.6.2",
"react-page-layout": "^0.9.8",
"react-phone-input-2": "^2.13.9",
"react-player": "^1.15.2",
"react-redux": "^7.2.0",
"react-router": "^5.0.0",
"react-router-dom": "^5.0.0",
"react-select": "^3.0.3",
"react-tenor": "^2.1.1",
"react-toastify": "^6.0.8",
"reactstrap": "^8.5.1",
"redux": "^4.0.5",
"redux-thunk": "^2.3.0",
"source-map-support": "^0.5.11",
"styled-components": "^5.0.0",
"universal-analytics": "^0.4.23",
"xml2js": "^0.4.19",
"zip-folder": "^1.0.0"
},
"devEngines": {
"node": ">=12.13.0",
"npm": ">=6.12.0",
"yarn": ">=1.19.0"
},
"browserslist": [
"defaults"
]
}

Nuxt js high CPU usage in dev environment

Since few updates my app front part in docker container doesn't work well
It use above 100% of Docker CPU, 60/70% of my laptop CPU (fans run at 100%)
And the HMR is very slow
This issue doesn't appear on production and on others laptops
I tried many things from different forums similar issues but nothing work
I reseted Docker to factory defaults settings, allowed more memory and CPU
I updated my dependencies
I removed and restored my node modules
I don't know what i should check to fix this issue
MacOS Catalina 10.15.4
Node v13.12.0
My package.json
{
"name": "front",
"version": "1.0.1",
"description": "My first-class Nuxt.js project",
"private": true,
"scripts": {
"dev": "nuxt",
"build": "nuxt build",
"start": "HOST=0.0.0.0 PORT=8080 nuxt start",
"generate": "nuxt generate",
"lint": "eslint --ext .js,.vue .",
"precommit": "npm run lint"
},
"config": {
"nuxt": {
"host": "0.0.0.0",
"port": "8080"
}
},
"dependencies": {
"#fullcalendar/core": "^4.3.1",
"#fullcalendar/daygrid": "^4.3.0",
"#fullcalendar/interaction": "^4.3.0",
"#fullcalendar/timegrid": "^4.3.0",
"#fullcalendar/vue": "^4.3.1",
"#nuxt/webpack": "^2.11.0",
"#nuxtjs/auth": "^4.5.3",
"#nuxtjs/axios": "^5.4.1",
"#nuxtjs/google-analytics": "^2.2.0",
"#nuxtjs/google-tag-manager": "^2.1.4",
"#nuxtjs/gtm": "^2.2.3",
"#nuxtjs/pwa": "^2.6.0",
"#nuxtjs/robots": "^2.0.0",
"#nuxtjs/router": "^1.3.2",
"#nuxtjs/sitemap": "^0.2.2",
"algoliasearch": "^4.1.0",
"cross-env": "^5.2.0",
"cxlt-vue2-toastr": "^1.1.0",
"date-fns": "^1.30.1",
"debug": "^4.1.1",
"gsap": "^2.1.3",
"jquery": "^3.4.1",
"libphonenumber-js": "^1.7.14",
"moment": "^2.24.0",
"node-sass": "^4.13.1",
"nuxt": "^2.11.0",
"nuxt-facebook-pixel-module": "^1.3.0",
"nuxt-google-maps-module": "^1.6.0",
"nuxt-jsonld": "^1.4.5",
"nuxt-token-auth": "^1.0.2",
"nuxt-user-agent": "^1.2.2",
"sass-loader": "^7.1.0",
"vee-validate": "^2.2.0",
"vue": "^2.6.11",
"vue-gallery": "^2.0.0",
"vue-i18n": "^8.10.0",
"vue-infinite-scroll": "^2.0.2",
"vue-instantsearch": "^2.7.0",
"vue-js-modal": "^1.3.33",
"vue-lazyload": "^1.2.6",
"vue-mq": "^1.0.1",
"vue-multiselect": "^2.1.6",
"vue-read-more": "^1.1.1",
"vue-scrollto": "^2.15.0",
"vue-sticky": "^3.3.4",
"vue-tawk": "^1.0.1",
"vue-upload-component": "^2.8.20",
"vue-wait": "^1.3.3",
"vue2-dropzone": "^3.5.8",
"vue2-leaflet": "^1.2.3",
"vuedraggable": "^2.20.0",
"vuejs-datepicker": "^1.5.4",
"vuejs-paginate": "^2.1.0",
"vueperslides": "^2.7.0"
},
"devDependencies": {
"babel-eslint": "^8.2.1",
"eslint": "^5.16.0",
"eslint-config-standard": "^12.0.0",
"eslint-loader": "^2.1.2",
"eslint-plugin-import": "^2.16.0",
"eslint-plugin-node": "^8.0.1",
"eslint-plugin-promise": "^4.0.1",
"eslint-plugin-standard": "^4.0.0",
"eslint-plugin-vue": "^4.7.1",
"nodemon": "^1.18.10"
}
}
Probably problem with the webpack's watch mode.
As stated here:
For some systems, watching many file systems can result in a lot of CPU or memory usage. It is possible to exclude a huge folder like node_modules
module.exports = {
//...
watchOptions: {
ignored: /node_modules/
}
};
In your case (nuxt.js), just add to nuxt.config.js
watchers: {
webpack: {
ignored: /node_modules/
}
}

Nodejs 12 + N-api version conflict

I'm trying to use the bcrypt-package inside a vue-electron project, but there is an N-api version issue when I try to run it:
Uncaught Error: The N-API version of this Node instance is 1. This module supports N-API version(s) 3. This Node instance cannot run this module.
I'm running node 12.16.1.
I read up on the documentation about N-API, and according to that version matrix, it is not possible I have version 1 installed. But I can't find any further documentation on how to install/configure/manage these N-API versions.
My package.json:
{
"version": "0.0.1",
"license": null,
"engines": {
"node": "12.16.x"
},
"main": "./dist/electron/main.js",
"scripts": {
"build": "node .electron-vue/build.js && electron-builder",
"build:dir": "node .electron-vue/build.js && electron-builder --dir",
"build:clean": "cross-env BUILD_TARGET=clean node .electron-vue/build.js",
"build:web": "cross-env BUILD_TARGET=web node .electron-vue/build.js",
"dev": "node .electron-vue/dev-runner.js",
"pack": "npm run pack:main && npm run pack:renderer",
"pack:main": "cross-env NODE_ENV=production webpack --progress --colors --config .electron-vue/webpack.main.config.js",
"pack:renderer": "cross-env NODE_ENV=production webpack --progress --colors --config .electron-vue/webpack.renderer.config.js",
"postinstall": ""
},
"build": {
"directories": {
"output": "build"
},
"files": [
"dist/electron/**/*"
],
"dmg": {
"contents": [
{
"x": 410,
"y": 150,
"type": "link",
"path": "/Applications"
},
{
"x": 130,
"y": 150,
"type": "file"
}
]
},
"mac": {
"icon": "build/icons/icon.icns"
},
"win": {
"icon": "build/icons/icon.ico"
},
"linux": {
"icon": "build/icons"
}
},
"dependencies": {
"#fortawesome/fontawesome-svg-core": "^1.2.27",
"#fortawesome/free-solid-svg-icons": "^5.12.1",
"#fortawesome/vue-fontawesome": "^0.1.9",
"axios": "^0.18.0",
"bcrypt": "^4.0.1",
"bootstrap": "^4.4.1",
"bootstrap-vue": "^2.7.0",
"dotenv": "^8.2.0",
"dotenv-webpack": "^1.7.0",
"mongoose": "^5.9.4",
"mongoose-uuid2": "^2.3.0",
"portal-vue": "^2.1.7",
"uuid": "^7.0.2",
"vue": "^2.5.16",
"vue-electron": "^1.0.6",
"vue-i18n": "^8.15.5",
"vue-router": "^3.0.1",
"vuex": "^3.0.1",
"vuex-electron": "^1.0.0"
},
"devDependencies": {
"ajv": "^6.5.0",
"babel-core": "^6.26.3",
"babel-loader": "^7.1.4",
"babel-minify-webpack-plugin": "^0.3.1",
"babel-plugin-transform-runtime": "^6.23.0",
"babel-preset-env": "^1.7.0",
"babel-preset-stage-0": "^6.24.1",
"babel-register": "^6.26.0",
"cfonts": "^2.1.2",
"chalk": "^2.4.1",
"copy-webpack-plugin": "^4.5.1",
"cross-env": "^5.1.6",
"css-loader": "^0.28.11",
"del": "^3.0.0",
"devtron": "^1.4.0",
"electron": "^2.0.4",
"electron-builder": "^20.19.2",
"electron-debug": "^1.5.0",
"electron-devtools-installer": "^2.2.4",
"file-loader": "^1.1.11",
"html-webpack-plugin": "^3.2.0",
"mini-css-extract-plugin": "0.4.0",
"multispinner": "^0.2.1",
"node-loader": "^0.6.0",
"style-loader": "^0.21.0",
"url-loader": "^1.0.1",
"vue-html-loader": "^1.2.4",
"vue-loader": "^15.2.4",
"vue-style-loader": "^4.1.0",
"vue-template-compiler": "^2.5.16",
"webpack": "^4.15.1",
"webpack-cli": "^3.0.8",
"webpack-dev-server": "^3.1.4",
"webpack-hot-middleware": "^2.22.2",
"webpack-merge": "^4.1.3"
}
}
Complete console stacktrace:
Uncaught Error: The N-API version of this Node instance is 1. This module supports N-API version(s) 3. This Node instance cannot run this module.
at Object.module.exports.validate_package_json (/home/fabian/projects/prelude-pos/node_modules/node-pre-gyp/lib/util/napi.js:82:9)
at Object.validate_config (/home/fabian/projects/prelude-pos/node_modules/node-pre-gyp/lib/util/versioning.js:229:10)
at Object.exports.find (/home/fabian/projects/prelude-pos/node_modules/node-pre-gyp/lib/pre-binding.js:21:15)
at Object.<anonymous> (/home/fabian/projects/prelude-pos/node_modules/bcrypt/bcrypt.js:5:27)
at Object.<anonymous> (/home/fabian/projects/prelude-pos/node_modules/bcrypt/bcrypt.js:238:3)
at Module._compile (module.js:642:30)
at Object.Module._extensions..js (module.js:653:10)
at Module.load (module.js:561:32)
at tryModuleLoad (module.js:504:12)
at Function.Module._load (module.js:496:3)
at Module.require (module.js:586:17)
at require (internal/module.js:11:18)
at eval (webpack-internal:///bcrypt:1:18)
at Object.bcrypt (http://localhost:9080/renderer.js:2844:1)
at __webpack_require__ (http://localhost:9080/renderer.js:727:30)
at fn (http://localhost:9080/renderer.js:102:20)
So far, I wiped and reinstalled nodejs, cleared the node_modules and reinstalled all the packages, but no difference there.
So I found an answer to my own question in the end:
Electron comes bundled with its own version of nodejs apparently. Updating electron fixed my error.

Resources