Electron command failed: npm prune --production - node.js

Trying to build Windows package from Electron using the below command:
electron-packager . --overwrite --asar=true --platform=win32 --arch=ia32 --icon=assets/icons/win/icon
.ico --prune=true --out=release-builds --version-string.CompanyName=CE --version-string.FileDescription=CE --version-string
.ProductName=\"Electron Tutorial App\"
It is giving me the below error:
Command failed: npm prune --production
npm ERR! May not delete: C:\Users\jessica\AppData\Local\Temp\electron-packager\win32-ia32\Tutorial-win32-ia32\resources\app
\node_modules\.bin
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\jessica\AppData\Roaming\npm-cache\_logs\2017-08-11T06_51_09_755Z-debug.log
I am on Angular 2. NPM version is: 5.3.0.
My package.json is below:
{
"productName": "invoice",
"version": "0.1.0",
"main": "main.js",
"license": "MIT",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"#angular/common": "^4.0.0",
"#angular/compiler": "^4.0.0",
"#angular/core": "^4.0.0",
"#angular/forms": "^4.0.0",
"#angular/http": "^4.0.0",
"#angular/platform-browser": "^4.0.0",
"#angular/platform-browser-dynamic": "^4.0.0",
"#angular/router": "^4.0.0",
"core-js": "^2.4.1",
"rxjs": "^5.1.0",
"zone.js": "^0.8.4"
},
"devDependencies": {
"#angular/cli": "1.0.2",
"#angular/compiler-cli": "^4.0.0",
"#types/jasmine": "2.5.38",
"#types/node": "~6.0.60",
"codelyzer": "~2.0.0",
"electron": "^1.7.5",
"jasmine-core": "~2.5.2",
"jasmine-spec-reporter": "~3.2.0",
"karma": "~1.4.1",
"karma-chrome-launcher": "~2.0.0",
"karma-cli": "~1.0.1",
"karma-coverage-istanbul-reporter": "^0.2.0",
"karma-jasmine": "~1.1.0",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~5.1.0",
"ts-node": "~2.0.0",
"tslint": "~4.5.0",
"electron-packager": "8.1.0",
"typescript": "~2.2.0"
}
}

As this user suggest here: https://github.com/electron-userland/electron-packager/issues/686
You should run
npm update -g npm
Then you can build your app again. It worked for me at least.

in my opinion the PATH is not correctly configured.
the easiest thing to do is to use the "cmd node" if you are on Windows

Related

Ng serve is working but ionic serve is failing

I'm building an app using Ionic 6.19.0 and it suddenly started to face building issues.
I get Error: spawn UNKNOWN each time I execute ionic serve.
This is my package.json file
{
"name": "stile",
"version": "0.0.1",
"author": "Ionic Framework",
"homepage": "https://ionicframework.com/",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"#angular-devkit/schematics": "^13.3.3",
"#angular/common": "~13.0.0",
"#angular/core": "~13.0.0",
"#angular/forms": "~13.0.0",
"#angular/platform-browser": "~13.0.0",
"#angular/platform-browser-dynamic": "~13.0.0",
"#angular/router": "~13.0.0",
"#auth0/angular-jwt": "^5.0.2",
"#capacitor/android": "3.4.3",
"#capacitor/app": "1.1.0",
"#capacitor/camera": "^1.3.1",
"#capacitor/core": "3.4.0",
"#capacitor/haptics": "1.1.4",
"#capacitor/keyboard": "1.2.1",
"#capacitor/status-bar": "1.0.7",
"#ionic/angular": "^6.0.0",
"#npmcli/node-gyp": "^2.0.0",
"bootstrap": "^5.1.3",
"install": "^0.13.0",
"jquery": "^3.6.0",
"json-server": "^0.17.0",
"node-sass": "^7.0.1",
"npm": "^8.6.0",
"rxjs": "~6.6.0",
"tslib": "^2.3.1",
"zone.js": "~0.11.4"
},
"devDependencies": {
"#angular-devkit/build-angular": "^13.3.3",
"#angular-eslint/builder": "^12.2.1",
"#angular-eslint/eslint-plugin": "~13.0.1",
"#angular-eslint/eslint-plugin-template": "~13.0.1",
"#angular-eslint/template-parser": "~13.0.1",
"#angular/cli": "~13.0.1",
"#angular/compiler": "~13.0.0",
"#angular/compiler-cli": "~13.0.0",
"#angular/language-service": "~13.0.0",
"#capacitor/cli": "3.4.0",
"#ionic/angular-toolkit": "^6.1.0",
"#popperjs/core": "^2.11.5",
"#types/jasmine": "~3.6.0",
"#types/jasminewd2": "~2.0.3",
"#types/node": "^12.11.1",
"#typescript-eslint/eslint-plugin": "5.3.0",
"#typescript-eslint/parser": "5.3.0",
"acorn": "^8.7.0",
"ajv": "^6.12.6",
"eslint": "^7.6.0",
"eslint-plugin-import": "2.22.1",
"eslint-plugin-jsdoc": "30.7.6",
"eslint-plugin-prefer-arrow": "1.2.2",
"jasmine-core": "~3.8.0",
"jasmine-spec-reporter": "~5.0.0",
"karma": "~6.3.2",
"karma-chrome-launcher": "~3.1.0",
"karma-coverage": "~2.0.3",
"karma-coverage-istanbul-reporter": "~3.0.2",
"karma-jasmine": "~4.0.0",
"karma-jasmine-html-reporter": "^1.5.0",
"protractor": "~7.0.0",
"ts-node": "~8.3.0",
"typescript": "~4.4.4"
},
"description": "An Ionic project"
}
Here are few solutions that might help:
Ensure you're in the root folder of your project.
Try fixing the existing node_modules folder with npm rebuild + reassign
permissions to your node_modules folder: chmod 755 -R
/path/to/node_modules
Remove node_modules and reinstall with npm install

Cannot open older Angular project with latest Angular version? [duplicate]

This question already has answers here:
How to ng serve an older Angular project?
(3 answers)
Closed 1 year ago.
I have just installed latest versions of Node.js (v14.16.1) and Angular (11.2).
Our TA gave us Angular project, but I cannot ng sever-it on my machine. I get following error:
An unhandled exception occurred: No projects support the 'serve' target.
See "C:\Users\Miljan\AppData\Local\Temp\ng-hVo6jS\angular-errors.log" for further details.
When I open the angular-errors.log, I have following output:
[error] Error: No projects support the 'serve' target.
at ServeCommand.initialize (C:\Users\Miljan\AppData\Roaming\npm\node_modules\#angular\cli\models\architect-command.js:58:19)
at async ServeCommand.validateAndRun (C:\Users\Miljan\AppData\Roaming\npm\node_modules\#angular\cli\models\command.js:127:9)
at async Object.runCommand (C:\Users\Miljan\AppData\Roaming\npm\node_modules\#angular\cli\models\command-runner.js:204:24)
at async default_1 (C:\Users\Miljan\AppData\Roaming\npm\node_modules\#angular\cli\lib\cli\index.js:80:31)
Here you can download Angular project which TA gave us.
And bellow is package.json from TA's project:
{
"name": "blog-client",
"version": "0.0.0",
"license": "MIT",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"#angular/animations": "^5.0.0",
"#angular/common": "^5.0.0",
"#angular/compiler": "^5.0.0",
"#angular/core": "^5.0.0",
"#angular/forms": "^5.0.0",
"#angular/http": "^5.0.0",
"#angular/platform-browser": "^5.0.0",
"#angular/platform-browser-dynamic": "^5.0.0",
"#angular/router": "^5.0.0",
"bootstrap": "^3.3.7",
"core-js": "^2.4.1",
"rxjs": "^5.5.2",
"zone.js": "^0.8.14"
},
"devDependencies": {
"#angular/cli": "1.5.0",
"#angular/compiler-cli": "^5.0.0",
"#angular/language-service": "^5.0.0",
"#types/jasmine": "~2.5.53",
"#types/jasminewd2": "~2.0.2",
"#types/node": "~6.0.60",
"codelyzer": "~3.2.0",
"jasmine-core": "~2.6.2",
"jasmine-spec-reporter": "~4.1.0",
"karma": "~1.7.0",
"karma-chrome-launcher": "~2.1.1",
"karma-cli": "~1.0.1",
"karma-coverage-istanbul-reporter": "^1.2.1",
"karma-jasmine": "~1.1.0",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~5.1.2",
"ts-node": "~3.2.0",
"tslint": "~5.7.0",
"typescript": "~2.4.2"
}
}
Okay, I managed it.
First npm install, npm run-script build, finally ng serve.
This helped How to ng serve an older Angular project?

not install node_modules when I type this command "npm install"

when i install node_modules with this command
npm install, I get below errors.
in this case, how can fix this errors?
npm ERR! errno HPE_INVALID_CONSTANT
npm ERR! request to https://registry.npmjs.org/acorn/-/acorn-5.7.2.tgz failed, reason: Parse Error
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\IR-16\AppData\Roaming\npm-cache\_logs\2019-03-25T10_35_26_869Z-debug.log
my package.json is following:
{
"name": "discover",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"#angular/animations": "^6.1.0",
"#angular/common": "^6.1.0",
"#angular/compiler": "^6.1.0",
"#angular/core": "^6.1.0",
"#angular/forms": "^6.1.0",
"#angular/http": "^6.1.0",
"#angular/platform-browser": "^6.1.0",
"#angular/platform-browser-dynamic": "^6.1.0",
"#angular/router": "^6.1.0",
"angular2-useful-swiper": "^5.0.1",
"bootstrap": "^4.1.3",
"core-js": "^2.5.4",
"ng-simple-slideshow": "^1.2.4",
"ngx-toggle-switch": "^2.0.5",
"ngx-ui-switch": "^1.6.0",
"rxjs": "^6.0.0",
"swiper": "3.4.2",
"zone.js": "~0.8.26"
},
"devDependencies": {
"#angular-devkit/build-angular": "~0.7.0",
"#angular/cli": "~6.1.5",
"#angular/compiler-cli": "^6.1.0",
"#angular/language-service": "^6.1.0",
"#types/jasmine": "~2.8.6",
"#types/jasminewd2": "~2.0.3",
"#types/node": "~8.9.4",
"codelyzer": "~4.2.1",
"jasmine-core": "~2.99.1",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~1.7.1",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "~2.0.0",
"karma-jasmine": "~1.1.1",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~5.4.0",
"ts-node": "~5.0.1",
"tslint": "~5.9.1",
"typescript": "~2.7.2"
}
}
as you can see, never installed acorn package.
this error happens when i install ````node modules``` in all projects.
Please remove "acorn": "^5.7.2", from package.json related acorn and follow the following steps,
rm -rf node_modules/
npm install
Then install acorn manually via terminal
npm install acorn --save
If it will not work then you can try with
npm install acorn --unsafe-perm --save
Hope this will help you !!

heroku/node deployment - cannot find module 'app/dist/server/app.js'

I've recently upgraded my angular2 app to angular 5 and I am having trouble deploying it to heroku where it used to work beforehand.
The issue here is that I have a Procfile that has this: 'web: node dist/server/app.js' - where the launch file is stored but heroku is trying to find it add this path - 'app/dist/server/app.js' I'm not sure where this /app is getting appended but it is causing the issue.
Cheers
error description
{
"name": "",
"version": "4.2.4",
"license": "",
"author": "",
"description": "",
"angular-cli": {},
"engines": {
"node": "8.9.4",
"npm": "5.6.0"
},
"scripts": {
"ng": "ng",
"build": "ng build --prod",
"start": "node dist/server/app.js",
"predev": "tsc -p server",
"dev": "node ./node_modules/mongodb-migrate -runmm -dbn dbSettings up && concurrently \"mongod\" \"ng serve -pc proxy.conf.json --open\" \"tsc -w -p server\" \"nodemon dist/server/app.js\"",
"prod": "concurrently \"mongod\" \"ng build -aot -prod && tsc -p server && node dist/server/app.js\"",
"test": "ng test",
"testbe": "tsc -p server && mocha dist/server/test --exit",
"lint": "ng lint",
"lintbe": "tslint server/**/**.ts{,x}",
"e2e": "ng e2e",
"migrations": "node ./node_modules/mongodb-migrate -runmm -dbn dbSettings up",
"create-migration": "node ./node_modules/mongodb-migrate -runmm create"
},
"private": true,
"dependencies": {
"#angular/animations": "^5.2.0",
"#angular/cdk": "2.0.0-beta.12",
"#angular/common": "^5.2.0",
"#angular/compiler": "^5.2.0",
"#angular/core": "^5.2.0",
"#angular/forms": "^5.2.0",
"#angular/http": "^5.2.0",
"#angular/material": "2.0.0-beta.12",
"#angular/platform-browser": "^5.2.0",
"#angular/platform-browser-dynamic": "^5.2.0",
"#angular/router": "^5.2.0",
"#sendgrid/mail": "^6.2.1",
"angular-bootstrap-md": "^5.1.2",
"angular2-jwt": "^0.2.3",
"bcryptjs": "^2.4.3",
"body-parser": "^1.18.2",
"bootstrap": "4.0.0-alpha.5",
"cheerio": "^1.0.0-rc.2",
"core-js": "^2.4.1",
"cron": "^1.3.0",
"dotenv": "^4.0.0",
"express": "^4.16.3",
"font-awesome": "^4.7.0",
"hammerjs": "^2.0.8",
"jquery": "^3.3.1",
"jsonwebtoken": "^8.2.1",
"migrate-mongo": "^2.2.1",
"moment": "^2.20.1",
"mongodb-migrate": "^2.0.2",
"mongoose": "^5.0.13",
"morgan": "^1.9.0",
"popper.js": "^1.14.3",
"npm-check": "^5.6.0",
"redis": "^2.8.0",
"request": "^2.85.0",
"rxjs": "^5.5.6",
"tether": "1.4.0",
"zone.js": "^0.8.19"
},
"devDependencies": {
"#angular/cli": "~1.7.3",
"#angular/compiler-cli": "^5.2.0",
"#angular/language-service": "^5.2.0",
"#types/jasmine": "^2.8.6",
"#types/jasminewd2": "~2.0.2",
"#types/node": "~6.0.60",
"chai": "^4.1.2",
"chai-http": "^4.0.0",
"codelyzer": "~4.0.1",
"concurrently": "^3.5.1",
"jasmine-core": "~2.8.0",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~2.0.0",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "^1.2.1",
"karma-jasmine": "~1.1.0",
"karma-jasmine-html-reporter": "^0.2.2",
"mocha": "^5.0.5",
"nodemon": "^1.17.3",
"protractor": "~5.1.2",
"ts-node": "~4.1.0",
"tslint": "~5.9.1",
"typescript": "~2.5.3"
}
}
I once came across with a similar issue with a nodejs typescript application that I had connected with git. The .gitingnore file omits js files. So when heroku takes a pull from git it only obtains typescript script(no js files). Where as the npm start script refers to js files.
Another thing to note it that heroku runs only two commands
npm install
and
npm start
Solution
Add ng build into the start script so that production files are available for heroku.
package.json
"ng": "ng",
"build": "ng build --prod",
"start": "ng build --prod && node dist/server/app.js",

Angular App not deployong on Heroku

I'm trying to deploy an angular 2 application on Heroku, and I followed a guide and keep getting this error. The error is probably about the postinstall, but I need the postinstall for deployment I read. I have already npm installed #angular/cli#latest Any one have an idea?
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! node-sass#4.7.2 postinstall: `node scripts/build.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the node-sass#4.7.2 postinstall script.
npm ERR! This is probably not a problem with npm. There is likely
additional logging output above.
Below is my package.json
{
"name": "mars-colony",
"version": "0.0.0",
"license": "MIT",
"scripts": {
"ng": "ng",
"start": "node server.js",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e",
"postinstall":"ng build --aot --target=production"
} ,
"private": true,
"dependencies": {
"#angular/common": "^2.4.0",
"#angular/cli": "1.0.0-rc.0",
"#angular/compiler-cli": "^2.4.0",
"#angular/compiler": "^2.4.0",
"#angular/core": "^2.4.0",
"#angular/forms": "^2.4.0",
"#angular/http": "^2.4.0",
"#angular/platform-browser": "^2.4.0",
"#angular/platform-browser-dynamic": "^2.4.0",
"#angular/router": "^3.4.0",
"core-js": "^2.4.1",
"ng2-page-transition": "^1.0.4",
"rxjs": "^5.1.0",
"typescript": "~2.0.0",
"web-animations-js": "^2.2.2",
"zone.js": "^0.7.6"
},
"devDependencies": {
"#types/jasmine": "2.5.38",
"#types/node": "~6.0.60",
"codelyzer": "~2.0.0",
"jasmine-core": "~2.5.2",
"jasmine-spec-reporter": "~3.2.0",
"karma": "~1.4.1",
"karma-chrome-launcher": "~2.0.0",
"karma-cli": "~1.0.1",
"karma-coverage-istanbul-reporter": "^0.2.0",
"karma-jasmine": "~1.1.0",
"karma-jasmine-html-reporter": "^0.2.2",
"node-sass": "^4.5.0",
"protractor": "~5.1.0",
"ts-node": "~2.0.0",
"tslint": "~4.4.2"
},
"engines": {
"node": "8.9.4",
"npm": "5.6.0"
}
}
I am not too familiar with node, but everything seems to be set up correctly like the guide has said. Below is my repo
https://github.com/edwardlanto/mars-heroku
Thank you!

Resources