I am going to compile web-pack i have got issue in that i.e Allocation failed - process out of memory .I know i can increase the space size using this
--max_old_space_size=8192
i tried many ways to fix this but nothing is working.
here is my package.json
"scripts": {
"karma": "karma",
"test": "karma start",
"rimraf": "rimraf",
"tslint": "tslint",
"typedoc": "typedoc",
"webpack": "webpack --progress --profile --bail",
"webpack-dev-server": "webpack-dev-server",
"webdriver-manager": "webdriver-manager",
"clean": "npm cache clean && npm run rimraf -- node_modules doc coverage dist compiled dll",
"clean:dist": "npm run rimraf -- dist",
"clean:dll": "npm run rimraf -- dll",
"clean:electron": "npm run rimraf -- build",
"preclean:install": "npm run clean",
"clean:install": "npm set progress=false && npm install",
"preclean:start": "npm run clean",
"clean:start": "npm start",
"watch": "npm run watch:dev",
"watch:dev": "npm run build:dev -- --watch",
"watch:dev:hmr": "npm run watch:dev -- --hot",
"watch:prod": "npm run build:prod -- --watch",
"build": "npm run build:dev",
"prebuild:dev": "npm run clean:dist",
"build:dev": " npm run clean:dist && npm run webpack -- --config config/webpack.dev.js",
"prebuild:prod": "npm run clean:dist",
"build:prod": "npm run clean:dist && webpack --config config/webpack.prod.js --progress --profile",
"server": "npm run server:dev",
"server:dev": "webpack-dev-server --config config/webpack.dev.js --progress --profile --watch --content-base src/",
"server:dev:hmr": "npm run server:dev -- --inline --hot",
"server:prod": "http-server dist -c-1 --cors",
"server:test": "http-server dist-demo -c-1 --cors",
"server:prod:ci": "http-server dist -p 3000 -c-1 --cors",
"webdriver:update": "npm run webdriver-manager update",
"webdriver:start": "npm run webdriver-manager start",
"lint": "npm run tslint \"src/**/*.ts\" --force",
"ngc": "./node_modules/.bin/ngc-w -p tsconfig.webpack.json",
"pree2e": "npm run webdriver:update -- --standalone",
"pretest": "npm run lint",
"docs": "npm run typedoc -- --options typedoc.json --exclude '**/*.spec.ts' ./src/",
"gh-pages": "wintersmith build -C docs && gh-pages -d docs/build",
"start": "npm run server:dev",
"start:hmr": "npm run server:dev:hmr",
"version": "npm run build",
"postversion": "git push && git push --tags",
"build:electron": "npm run build:electron.full",
"prebuild:electron.full": "npm run clean:electron",
"build:electron.full": "npm run build:electron.renderer && npm run build:electron.main",
"postbuild:electron.full": "npm run electron:start",
"build:electron.renderer": "npm run webpack -- --config config/electron/webpack.renderer.prod.js",
"build:electron.main": "npm run webpack -- --config config/electron/webpack.electron.prod.js",
"electron:start": "electron build",
"build:aot:prod": "npm run clean:dist && npm run clean:aot && webpack --config config/webpack.prod.js --progress --profile --bail",
"build:aot": "npm run build:aot:prod",
"clean:aot": "npm run rimraf -- compiled",
"build:ci": "npm run build:prod && npm run build:aot"
},
and the command for running my package.json is
npm server
please help my out how i increase size.
I had similar issue. I was using node version 8.x. Downgrading it to 6.11.0 resolved my issue.
Related
Compiling takes more than 20-22 seconds. I trying to improve the compiling speed of typescript node backend.
I'm using windows 11 bash terminal, computer not very bad (Intel(R) Core(TM) i7-9750H CPU # 2.60GHz, 2592 Mhz, 6 Core, 12 thread). Same build completes much faster on macOS.
Here is the my scripts;
"scripts": {
"start": "npx ts-node",
"dev": "npx nodemon --watch src src/index.ts",
"production": "npx ts-node ./src/index.ts",
"build": "npx tsc -p tsconfig.json && npx tscpaths -p tsconfig.json -s ./src -o ./build",
"build:run": "npm run build && npm run production",
"lint": "tslint -c tslint.json --project tsconfig.json",
"test": "jest --config jest.config.js",
"watch": "npm run build && npm run start",
"watch:lint": "npm run lint -- --watch",
"watch:test": "npm run test -- --watch",
"watch:build": "npm run build -- --watch",
"watch:start": "npm run start -- --watch"
},
What would you recommend me?
I have an app that works at local computer, built with angular, node and npm. I have deployed it to Heroku and got the error that binding to port was unsuccessful. Later on, I added a server.js file, changed my start command to "node server.js" and binding to port issue was solved. However, in this case the connection to backend does not work.
Is there a way to bind to the port without being forced to create server.js file and running the app only with "ng serve" command at heroku?
my package.json for frontend
"preinstall": "npm install -g --save-dev #angular-devkit/build-angular #angular/cli#11.2.14",
"ngcc": "ngcc",
"postinstall": "npm run ngcc",
"postupdate": "npm link #angular/cli",
"ng": "ng",
"start": "node server.js",
"start:ssl": "npm version && ng serve --configuration=development --ssl true --ssl-key ./ssl/localhost.key --ssl-cert ./ssl/localhost.cert",
"start:prod": "npm version && cross-env NODE_OPTIONS=\"--max-old-space-size=4096\" ng serve --prod",
"start:prod:ssl": "npm version && cross-env NODE_OPTIONS=\"--max-old-space-size=4096\" ng serve --prod --ssl true --ssl-key ./ssl/localhost.key --ssl-cert ./ssl/localhost.cert",
"build": "npm run build:dev && cd evserverch && npm install && npm run build",
"build:prod": "npm version && cross-env NODE_OPTIONS=\"--max-old-space-size=4096\" ng build --prod --stats-json",
"build:dev": "npm version && ng build --configuration=development --stats-json",
my package.json for backend
"start": "npm version && npm run start:prod",
"bundle": "webpack --config webpack.config.js",
"prestart": "npm run build:prod bundle",
"preinstall": "npm install --global webpack --save-dev webpack-cli webpack-node-externals --save-dev",
"config:batch": "ncp src/assets/configs-scp/e-Mobility-config/config_batch_server.json dist/assets/config.json",
"config:oData": "ncp src/assets/configs-scp/e-Mobility-config/config_odata_server.json dist/assets/config.json",
"config:fakerest": "ncp src/assets/configs-scp/e-Mobility-config/config_fake_rest_server.json dist/assets/config.json",
"config:ocpi": "ncp src/assets/configs-scp/e-Mobility-config/config_ocpi_server.json dist/assets/config.json",
"config:rest": "ncp src/assets/configs-scp/e-Mobility-config/config_rest_server.json dist/assets/config.json",
"config:chargebox-json": "ncp src/assets/configs-scp/e-Mobility-config/config_chargebox_json_server.json dist/assets/config.json",
"config:chargebox-soap": "ncp src/assets/configs-scp/e-Mobility-config/config_chargebox_soap_server.json dist/assets/config.json",
"start:dev": "npm version && cross-env NODE_ENV=development ts-node-dev --files --max-old-space-size=4096 -- src/start.ts",
"start:dev:debug": "npm version && cross-env NODE_ENV=development ts-node-dev --inspect --files --max-old-space-size=4096 -- src/start.ts",
"start:dev:nodemon": "npm version && nodemon --exec 'ts-node --files' src/start.ts",
"start:dev:debug:nodemon": "npm version && nodemon --exec 'ts-node --files' src/start.ts 9229",
"start:dev:prof": "npm version && cross-env NODE_OPTIONS=\"--max-old-space-size=4096\" NODE_ENV=development node -r source-map-support/register --prof -- dist/start.js",
"start:dev:doctorprof": "npm version && cross-env NODE_OPTIONS=\"--max-old-space-size=4096\" NODE_ENV=development clinic doctor -- node -r source-map-support/register dist/start.js",
"start:dev:flameprof": "npm version && cross-env NODE_OPTIONS=\"--max-old-space-size=4096\" NODE_ENV=development clinic flame -- node -r source-map-support/register dist/start.js",
"start:dev:bubbleprof": "npm version && cross-env NODE_OPTIONS=\"--max-old-space-size=4096\" NODE_ENV=development clinic bubbleprof -- node -r source-map-support/register dist/start.js",
"start:devbuild": "npm version && cross-env NODE_OPTIONS=\"--max-old-space-size=4096\" NODE_ENV=development-build node -r source-map-support/register dist/start.js",
"start:prod": "npm version && cross-env NODE_OPTIONS=\"--max-old-space-size=4096\" NODE_ENV=production node -r source-map-support/register dist/start.js",
I have also two configuration files for backend and frontend. the backend folder is in frontend and called evserverch, here is server.js for frontend. There is none for backend, because backend is served as worker.
var express = require('express');
var app = express();
var path = require('path');
app.use(express.static('./dist/ev-dashboard'));
app.get('/*', function(req, res) {
res.sendFile('index.html', {root: 'dist/ev-
dashboard/'});});
app.listen(process.env.PORT || 8080);
in my package.json I have these scripts:
"scripts":
{
"lint": "./node_modules/.bin/eslint src",
"build": "npm run clean && npm run dev && npm run prod",
"tsc": "./node_modules/.bin/tsc",
"dev": "./node_modules/.bin/webpack --config webpack.dev.js",
"prod": "./node_modules/.bin/webpack --config webpack.prod.js",
"clean": "del /q inet-henge*.js* dist",
"watch": "./node_modules/.bin/webpack --config webpack.dev.js --watch",
"postinstall": "copy inet-henge.js \"..\\flask\\customer_topology\\static\""
}
But for some reason postinstall is completely ignored when i run npm run build. When I run it as standalone script, it runs, the file is copied to the new location. Path is correct. What could be the problem, I am on Windows
post<x> runs after <x> so postinstall runs after install and if you want a script to run after build it should be called postbuild See https://docs.npmjs.com/cli/v6/using-npm/scripts for more details.
I want to run a command like: npm run start:dev to make my node server runs but after webpack finished building bundles.
My current npm scripts are:
"scripts": {
"start": "node server/server.js",
"start:dev": "npm run build:prod & npm start",
"lint": "eslint *",
"build:dev": "webpack",
"build:prod": "webpack -p --env production",
"dev-server": "webpack-dev-server",
"test": "cross-env NODE_ENV=test jest --config=jest.config.json"
},
The current command will kick both operations together.
Typo: you don't actually want to use &, you want &&:
"start:dev": "npm run build:prod && npm start",
A single ampersand will background the run:build job and cause start to run concurrently.
I have Dockerfile:
FROM cloudron/base:0.10.0
ENV PATH /usr/local/node-6.9.5/bin:$PATH
WORKDIR /tmp
COPY package.json /tmp/
RUN npm config set registry http://registry.npmjs.org/ && npm install
WORKDIR /usr/src/app
COPY . /usr/src/app
RUN cp -a /tmp/node_modules /usr/src/app
RUN npm run build
EXPOSE 8000
CMD [ "npm", "run", "start:production" ]
if I run this by:
docker run -p 8000:8000 -t somename/appname
then
going to http://localhost:8000 works fine
but if I want go to http://localhost:8000/about I get error:
Cannot GET /about
What should I do to make it well configured ?
Of course my react app, works fine with such link using in development start.
EDIT:
"scripts": {
"clean": "rimraf dist",
"compile": "node build/scripts/compile",
"build": "npm run clean && cross-env NODE_ENV=production npm run compile",
"start": "cross-env NODE_ENV=development node build/scripts/start",
"start:production": "cross-env NODE_ENV=production node build/scripts/start",
"test": "cross-env NODE_ENV=test karma start build/karma.config",
"test:watch": "npm test -- --watch",
"lint": "eslint .",
"lint:fix": "npm run lint -- --fix"
},
looks like my start:production is not good..