So I upgraded to angular 4+ just so that I can leverage the universal package for server side rendering for SEO purposes. I implemented that in my existing angular 2+ project by upgrading it to angular 4+ and did all the necessary configuration from https://github.com/evertonrobertoauler/cli-universal-demo/commit/a2610286bd3db5d4f4cce4318d7c220c11963eb6.
There is only one difference I am using ng-bootstrap https://ng-bootstrap.github.io/#/home (v1.0.0-alpha.22). But when I run the node server using npm run start-u-dev I get this error for import keyword in ng-bootstrap.
app-ui#0.0.0 start-u-dev /Users/giric/Projects/apnaDoctor/webapp/appUI
ts-node src/server.ts
/appUI/node_modules/#ng-bootstrap/ng-bootstrap/accordion/accordion.module.js:1
(function (exports, require, module, __filename, __dirname) { import { NgModule } from '#angular/core';
^^^^^^
SyntaxError: Unexpected token import
at createScript (vm.js:53:10)
at Object.runInThisContext (vm.js:95:10)
at Module._compile (module.js:543:28)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load (module.js:439:3)
at Module.require (module.js:498:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/appUI/dist/ngfactory/src/app/app.server.module.ngfa
ctory.ts:18:1)
at Module._compile (module.js:571:32)
at Module.m._compile (/appUI/node_modules/ts-node/src/index.ts:406:23)
at Module._extensions..js (module.js:580:10)
at Object.require.extensions.(anonymous function) [as .ts]
(/webapp/appUI/node_mod
ules/ts-node/src/index.ts:409:12)
at Module.load (module.js:488:32)
pm ERR! Darwin 16.6.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "start-u-dev"
npm ERR! node v7.7.4
npm ERR! npm v4.1.2
npm ERR! code ELIFECYCLE
npm ERR! app-ui#0.0.0 start-u-dev: `ts-node src/server.ts`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the app-ui#0.0.0 start-u-dev script 'ts-node src/server.ts'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the app-ui package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! ts-node src/server.ts
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs app-ui
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls app-ui
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
This is what my package.json looks like
{
"name": "app-ui",
"version": "0.0.0",
"license": "MIT",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e",
"prestart": "npm install",
"postinstall": "bower install",
"prestart-u-dev": "npm install && ng build && ngc",
"start-u-dev": "ts-node src/server.ts",
"prestart-u-prod": "npm install && ng build --prod && ngc",
"start-u-prod": "ts-node src/server.ts"
},
"private": true,
"dependencies": {
"#angular/animations": "^4.0.1",
"#angular/cli": "^1.0.0-rc.1",
"#angular/common": "^4.0.1",
"#angular/compiler": "^4.0.1",
"#angular/compiler-cli": "^4.0.1",
"#angular/core": "^4.0.1",
"#angular/forms": "^4.0.1",
"#angular/http": "^4.0.1",
"#angular/platform-browser": "^4.0.1",
"#angular/platform-browser-dynamic": "^4.0.1",
"#angular/platform-server": "^4.0.1",
"#angular/router": "^4.0.1",
"#ng-bootstrap/ng-bootstrap": "^1.0.0-alpha.22",
"angular2-toaster": "^3.0.1",
"core-js": "^2.4.1",
"ng2-webstorage": "^1.5.1",
"rxjs": "^5.1.0",
"rxjs-es": "^5.0.0-beta.12",
"typescript": "^2.2.2",
"ui-router-ng2": "^1.0.0-beta.4",
"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",
"raw-loader": "^0.5.1",
"sass-loader": "^6.0.3",
"ts-node": "~2.0.0",
"tslint": "~4.4.2"
}
}
Update:
Earlier i removed angular2-toaster, but then i added it again just to make sure it wasn't just toaster module that is throwing the same error. Turns out, both angular2-toaster and ng-bootstrap threw the same error.
Update 2:
When I run the server using ng server, it works fine, no issues with using ng-bootstrap and angular2-toaster with angular 4+
Any suggestions? Thanks in advance.
For those trying to understand what the solution is, you basically want to use and whitelist angular2-toaster and other modules giving this issue.
if using angular-cli, use ng eject to create a webpack.config.js
install the webpack-node-externals dependency via npm install and add the following lines in the webpack.config.js file
const nodeExternals = require('webpack-node-externals');
module.exports = {
...
target: 'node',
externals: [nodeExternals({
whitelist: [
/^#ng-bootstrap\/ng-bootstrap/,
/^angular2\-toaster/,
]
})],
...
}
It is clearly a build issue - you don't seem to have a proper transpilation setup for your server-side code. Please note that ng-bootstrap (as any other Angular 2.x+ library!) is shipping code in the following manner:
unbundled ES2015 code (with imports)
UMD-bundled ES5 code (without imports)
If you want to run ng-bootstrap on the server you've got 2 choices: either setup proper transpilation pipeline and used unbundled code or import from a bundle (located in bundles folder).
If you decide to go with a ES5 bundle approach you should be importing from #ng-bootstrap/ng-bootstrap/dist/ng-bootstrap instead of just #ng-bootstrap/ng-bootstrap). But to be clear I wouldn't recommend it as you would have to have different imports in your server-side and client-side code.
I think you can create two module. One is for browser is imported ng-bootstrap, one is for server is not imported ng-bootstrap. I think you have to create one more module common to share component, service for browser module and server module. Modal doesn't render by server to SEO.
Related
I'm no expert with JavaScript, node, npm, Angular, etc. I am a newbie with TypeScript. But I have inherited a application and I need to maintain it to fix a cross-site cookie problem.
So, I'm trying to get the development environment set up. I am stuck at npm install with a complaint of not finding a module #angular-devkit/build-ng-packagr. The same error happens when I try to explicitly install that module. Here is the log (with lots of similar lines omitted):
$ npm install #angular-devkit/build-ng-packagr
ngx-charts#0.0.0 prepack /home/kbuchs/.npm/_cacache/tmp/git-clone-a312e0b2
npm run package
ngx-charts#0.0.0 package /home/kbuchs/.npm/_cacache/tmp/git-clone-a312e0b2
npm run build:lib
ngx-charts#0.0.0 build:lib /home/kbuchs/.npm/_cacache/tmp/git-clone-a312e0b2
ng build #swimlane/ngx-charts && npm run copy-files
Could not find module "#angular-devkit/build-ng-packagr" from "/home/kbuchs/.npm/_cacache/tmp/git-clone-a312e0b2".
Error: Could not find module "#angular-devkit/build-ng-packagr" from "/home/kbuchs/.npm/_cacache/tmp/git-clone-a312e0b2".
at Object.resolve (/usr/lib/node_modules/#angular/cli/node_modules/#angular-devkit/core/node/resolve.js:141:11)
at Observable.rxjs_1.Observable [as _subscribe] (/usr/lib/node_modules/#angular/cli/node_modules/#angular-devkit/architect/src/architect.js:132:40)
at Observable._trySubscribe (/usr/lib/node_modules/#angular/cli/node_modules/rxjs/internal/Observable.js:44:25)
at Observable.subscribe (/usr/lib/node_modules/#angular/cli/node_modules/rxjs/internal/Observable.js:30:22)
at /usr/lib/node_modules/#angular/cli/node_modules/rxjs/internal/Observable.js:99:19
at new Promise (<anonymous>)
at Observable.toPromise (/usr/lib/node_modules/#angular/cli/node_modules/rxjs/internal/Observable.js:97:16)
at BuildCommand.initialize (/usr/lib/node_modules/#angular/cli/models/architect-command.js:88:94)
at process._tickCallback (internal/process/next_tick.js:68:7)
at Function.Module.runMain (internal/modules/cjs/loader.js:834:11)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! ngx-charts#0.0.0 build:lib: `ng build #swimlane/ngx-charts && npm run copy-files`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the ngx-charts#0.0.0 build:lib script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm WARN Local package.json exists, but node_modules missing, did you mean to install?
npm ERR! A complete log of this run can be found in:
npm ERR! /home/kbuchs/.npm/_logs/2020-02-25T17_01_41_575Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! ngx-charts#0.0.0 package: `npm run build:lib`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the ngx-charts#0.0.0 package script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm WARN Local package.json exists, but node_modules missing, did you mean to install?
npm ERR! A complete log of this run can be found in:
npm ERR! /home/kbuchs/.npm/_logs/2020-02-25T17_01_41_608Z-debug.log
npm WARN tar ENOENT: no such file or directory, open '/home/kbuchs/git/host-analytics/node_modules/.staging/got-f7f3ba2c/package.json'
npm WARN tar ENOENT: no such file or directory, open '/home/kbuchs/git/host-analytics/node_modules/.staging/got-f7f3ba2c/index.js'
. . .
npm WARN #angular-devkit/build-ng-packagr#0.11.4 requires a peer of ng-packagr#^2.2.0 || ^3.0.0 || ^4.0.0 but none is installed. You must install peer dependencies yourself.
npm ERR! premature close
npm ERR! A complete log of this run can be found in:
npm ERR! /home/kbuchs/.npm/_logs/2020-02-25T15_51_50_301Z-debug.log
Somehow the build of ngx-charts is coming out of the package.json. Package.json has some scripts defined, but I don't know what would cause npm to want to start building when I just asked it to install.
Nothing ever gets installed in node_modules, by the way, for the above actions or any of what I describe below.
I'll insert my package.json at the bottom.
I have tried cleaning up to start from scratch. I removed the node_modules directory. Also removed ~/.npm/*. I tried all this using node version 13.
If I rename the package.json and package-lock.json files, I can install individual modules without a problem. With those files with their original names, I do note that trying to explicitly install a particular module, npm seems to run through building a full dependency tree for the contents of those files.
So, next, I tried to go back to the version of node that was current when the project was first created about 16 months ago, node 10.19.0. I installed the n module globally to do this (sudo npm install -g n). This changed the version of npm to 6.13.4. Still the same results were encountered.
I noticed the warning near the end about peer dependency of ng-packagr#^4.0.0 and tried to install that (npm install ng-packagr#^4.0.0). I got all the same errors but a different warning about a peer dependency on tsickle#>=0.34.0. Again,I tried npm install tsickle#>=0.34.0 and got all the same errors and more with a warning on a peer dependency on typescript#~3.7.2. So, I did sudo npm install -g typescript#~3.7.2 which worked fine with no errors or warnings. When I went back to try to install tsickle, again the errors came and the message about the peer dependency on typescript. It feels like I'm chasing my tail.
Can anyone suggest a way out?
My package.json:
{
"name": "analytics",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"build.dev": "ng build -c dev",
"build.staging": "ng build -c staging",
"build.master": "ng build -c prod",
"deploy.dev": "cp app.dev.yaml dist/app.yaml && gcloud app deploy dist/app.yaml",
"deploy.staging": "cp app.staging.yaml dist/app.yaml && gcloud beta app deploy dist/app.yaml",
"deploy.master": "cp app.prod.yaml dist/app.yaml && gcloud beta app deploy dist/app.yaml",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"#angular-devkit/build-ng-packagr": "~0.11.1",
"#angular/animations": "~7.1.0",
"#angular/common": "~7.1.0",
"#angular/compiler": "~7.1.0",
"#angular/core": "~7.1.0",
"#angular/forms": "~7.1.0",
"#angular/platform-browser": "~7.1.0",
"#angular/platform-browser-dynamic": "~7.1.0",
"#angular/router": "~7.1.0",
"#ng-bootstrap/ng-bootstrap": "^4.0.0",
"#priotas/angular-bootstrap-slider": "^1.1.26",
"#swimlane/ngx-charts": "github:swimlane/ngx-charts#master",
"#types/date-fns": "^2.6.0",
"auth0-js": "^9.8.2",
"bootstrap": "^4.0.0-beta.3",
"bootstrap-slider": "^10.3.4",
"compact-timezone-list": "^1.0.6",
"core-js": "^2.5.4",
"d3": "^5.7.0",
"date-fns": "^1.30.1",
"font-awesome": "^4.7.0",
"html2canvas": "^1.0.0-alpha.12",
"html2pdf": "0.0.11",
"jspdf": "^1.5.3",
"lodash": "^4.17.11",
"moment": "^2.22.2",
"moment-timezone": "^0.5.23",
"ng-multiselect-dropdown": "^0.2.3",
"ng2-timezone-selector": "^0.2.4",
"ngx-webstorage-service": "^3.1.1",
"print-js": "^1.0.54",
"rxjs": "~6.3.3",
"tslib": "^1.9.0",
"zone.js": "~0.8.26"
},
"devDependencies": {
"#angular-devkit/build-angular": "~0.11.0",
"#angular/cli": "~7.1.1",
"#angular/compiler-cli": "~7.1.0",
"#angular/language-service": "~7.1.0",
"#types/jasmine": "~2.8.8",
"#types/jasminewd2": "~2.0.3",
"#types/lodash": "^4.14.120",
"#types/node": "^8.10.45",
"codelyzer": "~4.5.0",
"jasmine-core": "~2.99.1",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~3.1.1",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "~2.0.1",
"karma-jasmine": "~1.1.2",
"karma-jasmine-html-reporter": "^0.2.2",
"ncp": "^2.0.0",
"protractor": "~5.4.0",
"ts-node": "~7.0.0",
"tslint": "~5.11.0",
"typescript": "~3.1.6"
}
}
Since this is an Angular 7 app, that points to it being older code, which makes me suspect that this is probably not a valid dependency:
"#swimlane/ngx-charts": "github:swimlane/ngx-charts#master",
since that's going to pull the current version of ngx-charts from github. Looking at releases, Angular 7.1.0 was released in Nov. 2018 (ref: https://github.com/angular/angular-cli/releases/tag/v.7.1.0); so I'd try using a version of ngx-charts that was contemporary to that (it looks like 10.0.0 or 10.1.0 would be good bets, per https://github.com/swimlane/ngx-charts/releases).
So ... to be safe:
rm -r package-lock.json node_modules
npm i --save #swimlane/ngx-charts#10.1.0
npm install
...see if that does the trick.
Failed Heroku deploy. Been looking at other similar stack overflow posts and changing package.json file trying solutions that have worked for others with no luck. I am not sure if this is a port issue, or a package.json issue or something completely different. Any help, tips or advice is greatly appreciated!
Heroku logs:
2019-02-09T08:32:56.609533+00:00 heroku[web.1]: State changed from crashed to starting
2019-02-09T08:33:00.956199+00:00 heroku[web.1]: Starting process with command `npm start`
2019-02-09T08:33:03.430137+00:00 heroku[web.1]: State changed from starting to crashed
2019-02-09T08:33:03.257739+00:00 app[web.1]:
2019-02-09T08:33:03.257781+00:00 app[web.1]: > the-lottery-genie-mean#0.0.0 start /app
2019-02-09T08:33:03.257783+00:00 app[web.1]: > ng serve
2019-02-09T08:33:03.257784+00:00 app[web.1]:
2019-02-09T08:33:03.294426+00:00 app[web.1]: sh: 1: ng: not found
2019-02-09T08:33:03.304958+00:00 app[web.1]: npm ERR! file sh
2019-02-09T08:33:03.305986+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2019-02-09T08:33:03.306367+00:00 app[web.1]: npm ERR! errno ENOENT
2019-02-09T08:33:03.309015+00:00 app[web.1]: npm ERR! syscall spawn
2019-02-09T08:33:03.310700+00:00 app[web.1]: npm ERR! the-lottery-genie-mean#0.0.0 start: `ng serve`
2019-02-09T08:33:03.310912+00:00 app[web.1]: npm ERR! spawn ENOENT
2019-02-09T08:33:03.311266+00:00 app[web.1]: npm ERR!
2019-02-09T08:33:03.311514+00:00 app[web.1]: npm ERR! Failed at the the-lottery-genie-mean#0.0.0 start script.
2019-02-09T08:33:03.314421+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2019-02-09T08:33:03.324652+00:00 app[web.1]:
2019-02-09T08:33:03.324892+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2019-02-09T08:33:03.325013+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2019-02-09T08_33_03_316Z-debug.log
2019-02-09T08:33:03.411224+00:00 heroku[web.1]: Process exited with status 1
package.json:
{
"name": "the-lottery-genie-mean",
"version": "0.0.0",
"scripts": {
"preinstall": "npm link #angular/cli ",
"heroku-postbuild": "ng build --prod",
"postinstall": "",
"ng": "ng",
"start": "node server.js",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"#angular/cli": "^7.1.4",
"#angular/compiler-cli": "~7.0.0",
"#angular/animations": "~7.0.0",
"#angular/common": "~7.0.0",
"#angular/compiler": "~7.0.0",
"#angular/core": "~7.0.0",
"#angular/forms": "~7.0.0",
"#angular/http": "~7.0.0",
"#angular/platform-browser": "~7.0.0",
"#angular/platform-browser-dynamic": "~7.0.0",
"#angular/router": "~7.0.0",
"core-js": "^2.5.4",
"json": "^9.0.6",
"rxjs": "~6.3.3",
"zone.js": "~0.8.26"
},
"devDependencies": {
"#angular-devkit/build-angular": "^0.13.1",
"#angular/language-service": "~7.0.0",
"#types/jasmine": "~2.8.8",
"#types/jasminewd2": "~2.0.3",
"#types/node": "~8.9.4",
"codelyzer": "~4.5.0",
"jasmine-core": "~2.99.1",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~3.0.0",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "~2.0.1",
"karma-jasmine": "~1.1.2",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~5.4.0",
"ts-node": "~7.0.0",
"tslint": "~5.11.0",
"typescript": "~3.1.1"
},
"engines": {
"node": "10.15.1",
"npm": "6.4.1"
}
}
server.js file
app.listen(PORT, '0.0.0.0', function () {
console.log("Node app is running at localhost:" + app.get('port'));
})
Did you check the debug log here /app/.npm/_logs/2019-02-09T08_33_03_316Z-debug.log ?
I suggest looking into the debug log first to get us more details to solve the problem.
UPDATE
Its an H10 error. "heroku[router]: at=error code=H10 desc="App crashed"
method=GET path="/favicon.ico" host=angular-lottery-genie.herokuapp.com
request_id=30e63a79-c395-4d2a-9987-938bcc350629 fwd="50.250.113.70" dyno=
connect= service= status=503 bytes= protocol=https"
Your app crashed. Here are some things you can do:
1.) Restart heroku. You should have heroku CLI installed. Here's the link: Heroku CLI Install . And run heroku restart on your terminal.
2.) Use port that Heroku dynamically sets which can be accessed usually at process.env.PORT, and set your desired port as backup:
app.listen(process.env.PORT || 3000, function(){
console.log("Node app is running at localhost:" + app.get('port'));
});
3.) Try to check your node and npm version by typing in your terminal:
node --version
npm --version
And update the node and npm versions indicated under your package.json file:
"engines": {
"node": "10.15.1",
"npm": "6.4.1"
}
Another UPDATE for your questions:
npm ERR! enoent ENOENT: no such file or directory
These errors are usually related to corruption or incompatibility of packages. What you can do:
1.) Make sure no other instances of node are running in the backgound and retry your npm command.
2.) Delete the node_modules directory and package-lock.json (if you have any). Reinstall packages running npm install (or any command you're using to install the packages) in your terminal inside your project directory.
3.) Upgrade node to the latest version, delete node_modules directory and package-lock.json, and reinstall the packages.
4.) If npm still does not work for you, try yarn package manager (Yarn).
5.) If packages installation still fail, check the error logs file for a detailed report of the error.
Hope this helps!
You might need to add the devkit/builder, make sure its in the right sequence. I added it in bold so make sure if you are gonna copy paste to remove the asterix from the beginning and end.
"#angular/cli": "^7.1.4",
"#angular/compiler-cli": "~7.0.0",
"#angular/animations": "~7.0.0",
"#angular/common": "~7.0.0",
"#angular/compiler": "~7.0.0",
"#angular/core": "~7.0.0",
"#angular/forms": "~7.0.0",
"#angular/http": "~7.0.0",
"#angular/platform-browser": "~7.0.0",
"#angular/platform-browser-dynamic": "~7.0.0",
"#angular/router": "~7.0.0",
**"#angular-devkit/build-angular": "^0.13.1",
"#angular/language-service": "~7.0.0",**
"core-js": "^2.5.4",
"json": "^9.0.6",
"rxjs": "~6.3.3",
"zone.js": "~0.8.26"
In my experience, the deployment of an app that works locally is not always straightforward in Heroku. There are several cases like this in StackOverflow without a definitive solution, specially related to "'library' not found". For someone with a similar problem (trying to deploy AngularJS in Heroku) I would recommend check first functional tutorials like these:
https://devcenter.heroku.com/articles/mean-apps-restful-api
Almost-Oficial documentation. It describes a more complex app but you can discard some things.
https://medium.com/better-programming/how-to-deploy-your-angular-9-app-to-heroku-in-minutes-51d171c2f0d This guy shows a working Angular tutorial deployed in Heroku.
move some devDependencies to dependencies (angular 9 example)
npm i #angular/cli #angular-devkit/build-angular #angular/compiler-cli typescript --save-prod
or set NPM_CONFIG_PRODUCTION to false
here is an answer to similar question
I've tried to unsuccessfully run a node app, which runs fine on both High Sierra and Windows 10, but fails on Mojave 10.14.1.
This is the error shown when running the gulp build_dev task:
[23:44:42] Requiring external module babel-register
fs.js:25
'use strict';
^
ReferenceError: internalBinding is not defined
at fs.js:25:1
at req_ (/Users/user1/Documents/NodeProjects/myapp/node_modules/natives/index.js:137:5)
at Object.req [as require] (/Users/user1/Documents/NodeProjects/myapp/node_modules/natives/index.js:54:10)
at Object.<anonymous> (/Users/user1/Documents/NodeProjects/myapp/node_modules/vinyl-fs/node_modules/graceful-fs/fs.js:1:37)
at Module._compile (internal/modules/cjs/loader.js:707:30)
at Module._extensions..js (internal/modules/cjs/loader.js:718:10)
at Object.require.extensions.(anonymous function) [as .js] (/Users/user1/Documents/NodeProjects/myapp/node_modules/babel-register/lib/node.js:152:7)
at Module.load (internal/modules/cjs/loader.js:605:32)
at tryModuleLoad (internal/modules/cjs/loader.js:544:12)
at Function.Module._load (internal/modules/cjs/loader.js:536:3)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! myapp#1.0.0 dev: `node node_modules/gulp/bin/gulp.js build_dev`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the myapp#1.0.0 dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/user1/.npm/_logs/2018-11-04T22_44_42_709Z-debug.log
This is the content of the package.json file with all the dependencies used in the application:
{
"name": "myapp",
"version": "1.0.0",
"description": "",
"main": "server.js",
"scripts": {
"test-dev": "node node_modules/gulp/bin/gulp.js test_dev",
"test-prod": "node node_modules/gulp/bin/gulp.js test_prod",
"dev": "node node_modules/gulp/bin/gulp.js build_dev",
"prod": "node node_modules/gulp/bin/gulp.js build_prod"
},
"author": "",
"license": "ISC",
"dependencies": {
"babel-polyfill": "^6.26.0",
"body-parser": "^1.17.2",
"cookie-parser": "^1.4.3",
"envify": "^4.1.0",
"express": "^4.16.2",
"glob": "^7.1.2",
"http-status-codes": "^1.1.6",
"morgan": "^1.8.2",
"multi-glob": "^1.0.1",
"npm": "^6.4.1",
"path": "^0.12.7"
},
"devDependencies": {
"babel-cli": "^6.24.1",
"babel-core": "^6.26.0",
"babel-plugin-syntax-async-functions": "^6.13.0",
"babel-plugin-transform-async-to-generator": "^6.24.1",
"babel-preset-env": "^1.6.0",
"babel-register": "^6.24.1",
"babelify": "^7.3.0",
"browser-sync": "^2.26.3",
"browserify": "^16.1.0",
"gulp": "^3.9.1",
"gulp-concat": "^2.6.1",
"gulp-if": "^2.0.2",
"gulp-imagemin": "^3.3.0",
"gulp-minify-css": "^1.2.4",
"gulp-nodemon": "^2.2.1",
"gulp-notify": "^3.0.0",
"gulp-rename": "^1.2.2",
"gulp-sass": "^3.1.0",
"gulp-sass-glob": "^1.0.8",
"gulp-sourcemaps": "^2.6.0",
"gulp-uglify": "^3.0.0",
"gulp-util": "^3.0.8",
"imagemin-pngquant": "^5.0.1",
"run-sequence": "^2.2.0",
"vinyl-buffer": "^1.0.0",
"vinyl-source-stream": "^1.1.0"
}
}
Any hint on how to debug this problem? Could be related to gcc compiler version?
node version: 11.1.0
npm version: 6.4.1
At this link I've uploaded the log of the "npm install" command to install dependencies: npm_install.log
Try updating natives to the latest version. This commit seems to resolve the issue you're having.
I downgraded Node version from 10.15.0(LTS) to 10.10.0. And this fixed internalBinding error for me.
sudo npm cache clean -f
sudo npm install -g n
sudo n 10.10.0
In my case, the issue was with the node_modules installation, so do the following.
Perform a yarn audit
Check if you have any critical vulnerabilities
Either upgrade the version of the module or search for an alternative module.
yarn install
You should be good to go
Note: Issue was not with the node version in my case it was just a vulnerable module(gulp-angular-templatecache). I also suggest you do npm upgrade and npm rebuild if the above method doesn't work.
npm audit doesn't work with private repositories but yarn audit does.
I am having problem with dependencies in my Angular 4 project. This is the package.json file:
{
"name": "angular-webpack-starter",
"version": "1.0.0",
"description": "A webpack starter for Angular",
"scripts": {
"start": "webpack-dev-server --hot --inline --progress --port 8080 --open",
"test": "karma start",
"build": "rimraf dist && webpack --config config/webpack.prod.js --progress --profile --bail"
},
"dependencies": {
"#angular/animations": "^4.2.5",
"#angular/common": "^4.2.5",
"#angular/compiler": "^4.2.5",
"#angular/compiler-cli": "^4.2.5",
"#angular/core": "^4.2.5",
"#angular/forms": "^4.2.5",
"#angular/http": "^4.2.5",
"#angular/platform-browser": "^4.2.5",
"#angular/platform-browser-dynamic": "^4.2.5",
"#angular/platform-server": "^4.2.5",
"#angular/router": "^4.2.5",
"core-js": "^2.4.1",
"ngx-infinite-scroll": "^0.5.1",
"rxjs": "5.4.1",
"zone.js": "^0.8.12",
"typescript": "^2.4.1"
},
"devDependencies": {
"#angular/cli": "^1.2.0",
"#angular/compiler-cli": "4.2.5",
"#types/core-js": "^0.9.42",
"#types/jasmine": "^2.5.53",
"#types/node": "^8.0.6",
"angular2-template-loader": "^0.6.2",
"awesome-typescript-loader": "^3.2.1",
"css-loader": "^0.28.4",
"file-loader": "^0.11.2",
"html-loader": "^0.4.5",
"html-webpack-plugin": "^2.29.0",
"jasmine": "^2.6.0",
"jasmine-core": "^2.6.4",
"karma": "^1.7.0",
"karma-chrome-launcher": "^2.2.0",
"karma-jasmine": "^1.1.0",
"karma-sourcemap-loader": "^0.3.7",
"karma-typescript": "^3.0.4",
"karma-webpack": "^2.0.3",
"node-sass": "^4.5.3",
"null-loader": "^0.1.1",
"raw-loader": "^0.5.1",
"rimraf": "^2.6.1",
"sass-loader": "^6.0.6",
"script-loader": "^0.7.0",
"style-loader": "^0.18.2",
"to-string-loader": "^1.1.5",
"typescript": "^2.4.1",
"typings": "^2.1.1",
"url-loader": "^0.5.9",
"webpack": "^3.0.0",
"webpack-dev-server": "^2.2.0",
"webpack-merge": "^4.1.0"
}
}
And upon running npm start I get the following error:
> webpack-dev-server --hot --inline --progress --port 8080 --open
C:\...project_folder...\node_modules\extract-text-webpack-plugin\index.js:187
throw new Error("Breaking change: extract now only takes a single argument. Either an options " +
^
Error: Breaking change: extract now only takes a single argument. Either an options object *or* the loader(s).
Example: if your old code looked like this:
ExtractTextPlugin.extract('style-loader', 'css-loader')
You would change it to:
ExtractTextPlugin.extract({ fallback: 'style-loader', use: 'css-loader' })
The available options are:
use: string | object | loader[]
fallback: string | object | loader[]
publicPath: string
at Function.ExtractTextPlugin.extract (C:\...project_folder...\node_modules\extract-text-webpack-plugin\index.js:187:9)
at Object.<anonymous> (C:\...project_folder...\config\webpack.common.js:35:30)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (C:\...project_folder...\config\webpack.dev.js:3:20)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)
npm ERR! Windows_NT 10.0.15063
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "start"
npm ERR! node v6.11.0
npm ERR! npm v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! angular-webpack-starter#1.0.0 start: `webpack-dev-server --hot --inline --progress --port 8080 --open`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the angular-webpack-starter#1.0.0 start script 'webpack-dev-server --hot --inline --progress --port 8080 --open'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the angular-webpack-starter package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! webpack-dev-server --hot --inline --progress --port 8080 --open
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs angular-webpack-starter
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls angular-webpack-starter
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! C:\...project_folder...\npm-debug.log
Does anyone know what seems to be the problem? I have tried changing the versions and deleting node_modules folder and running npm install, but the same thing happens each time.
In yourwebpack.config.jsfile
change
ExtractTextPlugin.extract('style-loader', 'css-loader')
to
ExtractTextPlugin.extract({ fallback: 'style-loader', use: 'css-loader' })
As, syntax is changed in latest version.
Hope,it will help!
Hello.
I have an wierd error. I recently reinstalled everything on my laptop. Now i ran into troubles. Everytime i use this config from package.json i get error pushing to heroku.
{
"name": "mrfrederiksen",
"version": "0.0.0",
"license": "MIT",
"scripts": {
"postinstall": "ng build --aot -prod",
"start": "node server.js"
},
"engines": {
"node": "7.7.3",
"npm": "4.1.2"
},
"private": true,
"dependencies": {
"#angular/cli": "1.0.0",
"#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",
"express": "^4.15.2",
"rxjs": "^5.1.0",
"zone.js": "^0.8.4"
},
"devDependencies": {
"#angular/compiler-cli": "^4.0.0",
"#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-jasmine": "~1.1.0",
"karma-jasmine-html-reporter": "^0.2.2",
"karma-coverage-istanbul-reporter": "^0.2.0",
"protractor": "~5.1.0",
"ts-node": "~2.0.0",
"tslint": "~4.5.0",
"typescript": "~2.2.0"
}
}
But...
If i use this giving from an friend who have older versions installed everything works.
{
"name": "mrfrederiksen",
"version": "0.0.0",
"license": "MIT",
"scripts": {
"postinstall": "ng build --aot -prod",
"start": "node server.js"
},
"engines": {
"node": "6.9.4",
"npm": "3.10.10"
},
"private": true,
"dependencies": {
"#angular/cli": "1.0.0-rc.0",
"#angular/common": "^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",
"express": "^4.15.2",
"rxjs": "^5.1.0",
"zone.js": "^0.7.6"
},
"devDependencies": {
"#angular/compiler-cli": "^2.4.0",
"#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-jasmine": "~1.1.0",
"karma-jasmine-html-reporter": "^0.2.2",
"karma-coverage-istanbul-reporter": "^0.2.0",
"protractor": "~5.1.0",
"ts-node": "~2.0.0",
"tslint": "~4.4.2",
"typescript": "~2.0.0"
}
}
Here is my error console messages when using my own with latest versions.
-----> Node.js app detected
-----> Creating runtime environment
NPM_CONFIG_LOGLEVEL=error
NPM_CONFIG_PRODUCTION=true
NODE_VERBOSE=false
NODE_ENV=production
NODE_MODULES_CACHE=true
-----> Installing binaries
engines.node (package.json): 7.7.3
engines.npm (package.json): 4.1.2
Downloading and installing node 7.7.3...
npm 4.1.2 already installed with node
-----> Restoring cache
Skipping cache restore (new runtime signature)
-----> Building dependencies
Installing node modules (package.json)
> node-sass#4.5.1 install /tmp/build_5a8b797790355e544758529cdf0f5b1a/node_modules/node-sass
> node scripts/install.js
Downloading binary from https://github.com/sass/node-sass/releases/download/v4.5.1/linux-x64-51_binding.node
Download complete
Binary saved to /tmp/build_5a8b797790355e544758529cdf0f5b1a/node_modules/node-sass/vendor/linux-x64-51/binding.node
Caching binary to /app/.npm/node-sass/4.5.1/linux-x64-51_binding.node
> node-sass#4.5.1 postinstall /tmp/build_5a8b797790355e544758529cdf0f5b1a/node_modules/node-sass
> node scripts/build.js
Binary found at /tmp/build_5a8b797790355e544758529cdf0f5b1a/node_modules/node-sass/vendor/linux-x64-51/binding.node
Testing binary
Binary is fine
> mrfrederiksen#0.0.0 postinstall /tmp/build_5a8b797790355e544758529cdf0f5b1a
> ng build --aot -prod
The "#angular/compiler-cli" package was not properly installed.
Error: The "#angular/compiler-cli" package was not properly installed.
at Object.<anonymous> (/tmp/build_5a8b797790355e544758529cdf0f5b1a/node_modules/#ngtools/webpack/src/index.js:14:11)
at Module._compile (module.js:571:32)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load (module.js:439:3)
at Module.require (module.js:498:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/tmp/build_5a8b797790355e544758529cdf0f5b1a/node_modules/#angular/cli/tasks/eject.js:10:19)
at Module._compile (module.js:571:32)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load (module.js:439:3)
at Module.require (module.js:498:17)
at require (internal/module.js:20:19)
npm ERR! Linux 3.13.0-112-generic
npm ERR! argv "/tmp/build_5a8b797790355e544758529cdf0f5b1a/.heroku/node/bin/node" "/tmp/build_5a8b797790355e544758529cdf0f5b1a/.heroku/node/bin/npm" "install" "--unsafe-perm" "--userconfig" "/tmp/build_5a8b797790355e544758529cdf0f5b1a/.npmrc"
npm ERR! node v7.7.3
npm ERR! npm v4.1.2
npm ERR! code ELIFECYCLE
npm ERR! mrfrederiksen#0.0.0 postinstall: `ng build --aot -prod`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the mrfrederiksen#0.0.0 postinstall script 'ng build --aot -prod'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the mrfrederiksen package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! ng build --aot -prod
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs mrfrederiksen
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls mrfrederiksen
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /tmp/build_5a8b797790355e544758529cdf0f5b1a/npm-debug.log
-----> Build failed
We're sorry this build is failing! You can troubleshoot common issues here:
https://devcenter.heroku.com/articles/troubleshooting-node-deploys
If you're stuck, please submit a ticket so we can help:
https://help.heroku.com/
Love,
Heroku
! Push rejected, failed to compile Node.js app.
! Push failed
After I upgraded the npm, node, typescript and ng-cli to its latest versions, I had a similar kind of issue.
Tried many things but nothing worked out.
(ended up with "The "#angular/compiler-cli" package was not properly installed" error).
Then did the following steps:
Create a new project (ng new [project_name]) with new versions
Start the above created project with no code written using 'npm start' successfully
Copied the old projects 'src' folder into the new project folder
Copied folders (bootstrap) in old project in the new project folder
Start the project using 'npm start'
Everything started to work as usual.
Just update typescript v2.2.1 and it works