Running Existing Angular Project locally - node.js

I am very new to Angular, I am trying to run an existing project of Angular on my machine. I have done a lot of tests and followed a lot of articles. But cannot run my project.
I have the project files like this:
I installed the nodejs on my system.
And followed the following instructions as per an article:
change directory to our repo
cd myproject
installing Cli according to project readme file.
npm install -g #angular/cli#1.3.2
install the repo with npm
npm install
install TypeScript typings
npm run typings-install
-- Gives error: npm ERR! missing script: typings-install
Then I try the following:
npm install --global
For following:
webpack (npm install --global webpack)
webpack-dev-server (npm install --global webpack-dev-server)
karma (npm install --global karma-cli)
protractor (npm install --global protractor)
typings (npm install --global typings)
typescript (npm install --global typescript)
start the server
npm start
-- Gives multiple error messages:
Such as:
npm ERR! code ELIFECYCLE
-- For this I tried "npm cache clean" and then deleted "node_modules" and then installed packages again using: "npm install --save"
Then tried again: npm start it gave me same error "npm ERR! code ELIFECYCLE"
Also, this error message:
Cannot find module 'webpack/lib/node/NodeTemplatePlugin'
For this, I tried "npm uninstall -g webpack"
and then: npm install --save-dev webpack webpack-cli html-webpack-plugin webpack-dev-server webpack-dev-middleware from this: Error: Cannot find module 'webpack/lib/node/NodeTemplatePlugin'
Tried running it again:
this time it gave me following error:
ERROR in ./node_modules/raw-loader!./node_modules/#angular/cli/node_modules/post
css-loader/lib??embedded!./node_modules/sass-loader/lib/loader.js??ref--8-3!./sr
c/styles.scss
Module build failed: Error: Cannot find module 'node-sass'
For this "Cannot find module 'node-sass'" I did the search again:
and found this command: npm install node-sass
i tried it and then tried starting again
Now I received ERROR in No NgModule metadata found for 'AppModule'.
And for this I tried the following from git cli issues 8798
remove the node_modules folder
rm -rf node_modules
remove the webpack
npm remove webpack
clean npm cahe
npm cache clean --force
install the latest version of angular cli
npm install --save-dev #angular/cli#latest
install the dependencies
npm install
now it's just testing
npm start our ng serve
Now it start giving me: Local workspace file ('angular.json') could not be found and wont work at all.
To resolve this: I did: ng update #angular/cli --migrate-only --from=1.7.4
Which remove the error: "Local workspace file ('angular.json') could not be found" but now it gives me error
ERROR in src/app/web-player/albums/album-context-menu/album-context-menu.compon
nt.ts(13,14): error TS2515: Non-abstract class 'AlbumContextMenuComponent' does
not implement inherited abstract member 'getAllTracks' from class 'ContextMenuC
mponent<Album>'.
src/app/web-player/artists/artist-context-menu/artist-context-menu.component.ts
13,14): error TS2515: Non-abstract class 'ArtistContextMenuComponent' does not
mplement inherited abstract member 'getAllTracks' from class 'ContextMenuCompon
nt<Artist>'.
src/app/web-player/context-menu/context-menu.component.ts(58,34): error TS2304:
Cannot find name 'TrackList'.
src/app/web-player/playlists/playlist-context-menu/playlist-context-menu.compon
nt.ts(15,14): error TS2515: Non-abstract class 'PlaylistContextMenuComponent' d
es not implement inherited abstract member 'getAllTracks' from class 'ContextMe
uComponent<Playlist>'.
What am i missing here? I tried a lot of articles from 3 days but cannot run it.
Also, I see different types of Warning and messages.
Read Me file in project:
# Client
This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 1.3.2.
## Development server
Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files.
## Code scaffolding
Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module`.
## Build
Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory. Use the `-prod` flag for a production build.
## Running unit tests
Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io).
## Running end-to-end tests
Run `ng e2e` to execute the end-to-end tests via [Protractor](http://www.protractortest.org/).
Before running the tests make sure you are serving the app via `ng serve`.
## Further help
To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI README](https://github.com/angular/angular-cli/blob/master/README.md).
Package.json file:
{
"name": "client",
"version": "0.0.0",
"license": "MIT",
"scripts": {
"ng": "ng",
"start": "ng serve --proxy-config proxy.conf.json --host 0.0.0.0",
"build": "ng build --prod --sourcemaps --build-optimizer",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"#angular/animations": "^5.1.2",
"#angular/common": "^5.1.2",
"#angular/compiler": "^5.1.2",
"#angular/core": "^5.1.2",
"#angular/forms": "^5.1.2",
"#angular/http": "^5.1.2",
"#angular/platform-browser": "^5.1.2",
"#angular/platform-browser-dynamic": "^5.1.2",
"#angular/router": "^5.1.2",
"bootstrap": "^4.0.0-beta",
"chart.js": "^2.7.0",
"copy-to-clipboard": "^3.0.8",
"core-js": "^2.5.1",
"hammerjs": "^2.0.8",
"moment": "^2.18.1",
"ng-lazyload-image": "^3.3.3",
"ngx-color-picker": "^4.3.4",
"normalize.css": "^7.0.0",
"perfect-scrollbar": "^0.8.1",
"popper.js": "^1.12.5",
"raven-js": "^3.18.1",
"rxjs": "^5.4.2",
"svg4everybody": "^2.1.4",
"tooltip.js": "^1.1.5",
"zone.js": "^0.8.18"
},
"devDependencies": {
"#angular/cli": "^1.6.2",
"#angular/compiler-cli": "^5.1.2",
"#angular/language-service": "^5.1.2",
"#types/hammerjs": "^2.0.35",
"#types/jasmine": "~2.5.53",
"#types/jasminewd2": "^2.0.3",
"#types/node": "~6.0.60",
"#types/popper.js": "^1.10.1",
"#types/youtube": "0.0.31",
"#types/clipboard": "^1.5.35",
"cheerio": "^1.0.0-rc.2",
"codelyzer": "~3.1.1",
"gulp": "^3.9.1",
"gulp-clean": "^0.3.2",
"gulp-filter": "^5.0.0",
"gulp-rename": "^1.2.2",
"gulp-svgmin": "^1.2.3",
"gulp-svgstore": "^6.1.0",
"jasmine-core": "~2.6.2",
"jasmine-spec-reporter": "~4.1.0",
"karma": "^1.7.1",
"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",
"material-design-icons": "^3.0.1",
"protractor": "~5.1.2",
"ts-node": "~3.2.0",
"tslint": "~5.7.0",
"typescript": "~2.4.2",
"webpack-bundle-analyzer": "^2.9.0"
}
}

Run the following commands
npm uninstall -g #angular/cli
npm cache verify
npm install -g #angular/cli#next
npm update
Then
ng serve
I hope it works now. Comment if u face any error while.

That should be much easier...
Take your project files as is
Run npm install
Since you have the package.json file, it will read all dependencies and install them.
Then run npm audit fix if needed (the terminal will tell you that).

try ng serve --open
it will compile your project and directly open in browser

rename the file .angular-cli.json to angular.json and re run the ng serve --open command.

Change the path of the directory in your local
cd my-repo
npm install
ng serve or ng serve --open
You will find the Localhost then.
To clean the cache:
npm cache clean

I also had need to setup existing angular project.
*cli version as per your package.json file
npm install -g #angular/cli#1.3.2
Then
npm install
Then
ng serve
I have tested, it is working here.

Related

error TS2707 Generic type 'ɵɵDirectiveDeclaration' requires between 6 and 8 type arguments

After installing angular material and adding angular material imports in app.module.ts to the project im having errors and all solutions didn't work so far. I have angular 14, node 16. First error, which in reality is way longer:
Error: node_modules/#angular/cdk/a11y/index.d.ts:152:18 - error TS2707: Generic type 'ɵɵDirectiveDeclaration' requires between 6 and 8 type arguments.
152 static ɵdir: i0.ɵɵDirectiveDeclaration<CdkAriaLive, "[cdkAriaLive]", ["cdkAriaLive"], { "politeness": "cdkAriaLive"; "duration": "cdkAriaLiveDuration"; }, {}, never, never, false, never>;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Error: node_modules/#angular/cdk/a11y/index.d.ts:175:18 - error TS2707: Generic type 'ɵɵDirectiveDeclaration' requires between 6 and 8 type arguments.
175 static ɵdir: i0.ɵɵDirectiveDeclaration<CdkMonitorFocus, "[cdkMonitorElementFocus], [cdkMonitorSubtreeFocus]", ["cdkMonitorFocus"], {}, { "cdkFocusChange": "cdkFocusChange"; }, never, never, false, never>;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Error: node_modules/#angular/cdk/a11y/index.d.ts:208:18 - error TS2707: Generic type 'ɵɵDirectiveDeclaration' requires between 6 and 8 type arguments.
208 static ɵdir: i0.ɵɵDirectiveDeclaration<CdkTrapFocus, "[cdkTrapFocus]", ["cdkTrapFocus"], { "enabled": "cdkTrapFocus"; "autoCapture": "cdkTrapFocusAutoCapture"; }, {}, never, never, false, never>;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Error: node_modules/#angular/cdk/bidi/index.d.ts:37:18 - error TS2707: Generic type 'ɵɵDirectiveDeclaration' requires between 6 and 8 type arguments.
37 static ɵdir: i0.ɵɵDirectiveDeclaration<Dir, "[dir]", ["dir"], { "dir": "dir"; }, { "change": "dirChange"; }, never, never, false, never>;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
{
"name": "highlight",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"watch": "ng build --watch --configuration development",
"test": "ng test"
},
"private": true,
"dependencies": {
"#angular/animations": "^14.2.4",
"#angular/cdk": "^15.0.0",
"#angular/common": "^14.2.4",
"#angular/compiler": "^14.2.4",
"#angular/core": "^14.2.4",
"#angular/forms": "^14.2.4",
"#angular/material": "^15.0.0",
"#angular/platform-browser": "^14.2.4",
"#angular/platform-browser-dynamic": "^14.2.4",
"#angular/router": "^14.2.4",
"#fortawesome/angular-fontawesome": "^0.11.1",
"#fortawesome/fontawesome-svg-core": "^6.2.0",
"#fortawesome/free-solid-svg-icons": "^6.2.0",
"#ng-bootstrap/ng-bootstrap": "^13.0.0",
"#popperjs/core": "^2.11.6",
"#syncfusion/ej2-angular-calendars": "^20.3.56",
"apexcharts": "^3.36.3",
"bootstrap": "^5.2.2",
"jwt-decode": "^3.1.2",
"ng-apexcharts": "^1.7.4",
"rxjs": "~6.6.0",
"tslib": "^2.3.0",
"zone.js": "~0.11.4"
},
"devDependencies": {
"#angular-devkit/build-angular": "^14.2.4",
"#angular/cli": "^14.2.4",
"#angular/compiler-cli": "^14.2.4",
"#angular/localize": "^14.2.4",
"#types/jasmine": "~3.8.0",
"#types/node": "^12.11.1",
"jasmine-core": "~3.8.0",
"karma": "~6.3.0",
"karma-chrome-launcher": "~3.1.0",
"karma-coverage": "~2.0.3",
"karma-jasmine": "~4.0.0",
"karma-jasmine-html-reporter": "~1.7.0",
"typescript": "4.7"
}
}
I tried to delete node_modules, .angular and npm install. Didn't work.
Next i tried to reinstall angular material - npm install --save #angular/material #angular/cdk - gave me error, but different one. Im suspecting this is showing more clear reason of my actual error. As suggested in error i tried commands npm install --legacy-peer-deps, --force, npm install --save --legacy-peer-deps ,did not work. Maybe someone have more experience and recognize the problem?
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: highlight#0.0.0
npm ERR! Found: #angular/common#14.2.12
npm ERR! node_modules/#angular/common
npm ERR! #angular/common#"^14.2.4" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer #angular/common#"^15.0.0 || ^16.0.0" from #angular/cdk#15.0.0
npm ERR! node_modules/#angular/cdk
npm ERR! #angular/cdk#"^15.0.0" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
My ng v outcome:
Angular CLI: 14.2.10
Node: 16.10.0
Package Manager: npm 7.24.0
OS: darwin x64
Angular: 14.2.12
... animations, common, compiler, compiler-cli, core, forms
... localize, platform-browser, platform-browser-dynamic, router
Package Version
---------------------------------------------------------
#angular-devkit/architect 0.1402.10
#angular-devkit/build-angular 14.2.10
#angular-devkit/core 14.2.10
#angular-devkit/schematics 14.2.10
#angular/cdk 15.0.1
#angular/cli 14.2.10
#angular/material 15.0.1
#schematics/angular 14.2.10
rxjs 6.6.7
typescript 4.7.4
I had the same error after running, ng update #angular/core#14 #angular/cl1#14. Some other packages were updated to v15.04 in my pacakge.json. I'm guessing these are all dependencies I should have chained to the ng update command to have them all update evenly to v14. The solution was just to downgrade the versions of all packages that were in v15 to the v14-lst.
I think that because my #angular/compiler and #angular/compiler-cli had been updated to v15 is what triggered the compilation error when running ng serve
Update:
Ran into this again after configuring all my linters.
I don't think you want to lint or check on build node modules unless you really need to. Having typescript check node modules is important especially if you don't want different packages or different copies of the same package having conflicting type declarations.
To solve this, under compiler options in your tsconfig.json add skipLibCheck: true
tsconfig.json
{
...
complilerOptions: {
...
"skipLibCheck": true
}
}
Here are the official docs on skipLibCheck
In my case- it solved by applying this command:
ng update #angular/cli #angular/core --allow-dirty --force
Then, remove '~' symbol from styles if it is there:
Replace #import "~#coreui/coreui-pro/scss/coreui"
with #import "#coreui/coreui-pro/scss/coreui"
This is a compatibility issue. If you installed any new package check their Github and their dependencies.
I had installed ng-bootstrap#14 and it required angular of version 15 but my project is angular 14 so i had to downgrade the package to 13 to fix this issue.
Had the same issue.
Go with ngrx/component 14.3.2, if you use Angular 14.
Or update directly to Angular 15.
I am also facing the same issue,
**error ts2707: generic type 'ɵɵdirectivedeclaration' requires between 6 and 8 type arguments.**
but don't worry its quite simple to solve this problem:-
you need to just update the angular from version 14 to 15.
the following command is
command :-
ng update #angular/cli #angular/core --allow-dirty --force
then your application run as you expect!
Good Luck!
I found a TEMPORARY solution, i had a same error and i went inside node_modules and commented error lines.
In my case it was one comment in node_modules/#angular/cdk/bidi/index.d.ts and couple more in node_modules/#angular/cdk/scrolling/index.d.ts, altho i do not know what caused this error and i dont know if comenting this lines will cause problems in the future, there ist need to explore it further.
I was also facing the exact issue, I simply first update my NodeJS ( from 16 to 18 from NodeJS official website), later-on I also need to update my angular cli/ angular core from version 14 to 15.
command :-ng update #angular/cli #angular/core --allow-dirty --force
I need to put --allow-dirty --force because I was getting this error :-
Error: Repository is not clean. Please commit or stash any changes before updating.
and my application again starts running expectedly.
After doing all, my issue got resolved and my application again start's working expectedly.
remove the "never" parameter at the end just after "false".
Or Update your angular version.

Can't build Angular project after upgrade from 8 to 9

I've done an upgrade of my Angular project from 8 to 9 by using the ng update tool. Locally (Windows) everything works fine, but when I'm trying to build the project in docker, I get the following error:
Step 6/11 : RUN npm run build
---> Running in d60f739a56f6
> check-it-frontend#0.0.0 build /app
> ng build --prod
Compiling #angular/core : es2015 as esm2015
ERROR in EINVAL: invalid argument, rename '/app/node_modules/#angular/core/core.d.ts' -> '/app/node_modules/#angular/core/core.d.ts.__ivy_ngcc_bak'
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! check-it-frontend#0.0.0 build: `ng build --prod`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the check-it-frontend#0.0.0 build 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! /root/.npm/_logs/2020-03-20T11_44_02_696Z-debug.log
The command '/bin/sh -c npm run build' returned a non-zero code: 1
The dockerfile:
FROM node:13.10.1-stretch as base
RUN apt-get update -qq && apt-get install -y build-essential
ADD . /app
WORKDIR /app
RUN npm ci
RUN npm run build
Dependencies:
"dependencies": {
"#angular/animations": "^9.0.7",
"#angular/cdk": "^8.2.3",
"#angular/common": "^9.0.7",
"#angular/compiler": "^9.0.7",
"#angular/core": "^9.0.7",
"#angular/forms": "^9.0.7",
"#angular/material": "^8.2.3",
"#angular/platform-browser": "^9.0.7",
"#angular/platform-browser-dynamic": "^9.0.7",
"#angular/router": "^9.0.7",
"core-js": "^2.4.1",
"rxjs": "^6.5.4",
"rxjs-compat": "^6.0.0-rc.0",
"tslib": "^1.10.0",
"zone.js": "~0.10.2"
},
"devDependencies": {
"#angular-devkit/build-angular": "~0.900.7",
"#angular/cli": "^9.0.7",
"#angular/compiler-cli": "^9.0.7",
"#angular/language-service": "^9.0.7",
"#types/jasmine": "~2.8.3",
"#types/jasminewd2": "~2.0.2",
"#types/node": "^12.11.1",
"codelyzer": "^5.1.2",
"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",
"node-sass": "^4.13.1",
"protractor": "~5.1.2",
"ts-node": "~4.1.0",
"tslint": "~5.9.1",
"typescript": "~3.7.5"
}
Anything I can do to fix it? Images for Angular 8 were fine. I've tried different node images, but nothing helped...
I'm not exactly sure what your issue is or what's causing it, but I did a quick search and stumbled upon this github issue. It concerns parallel builds (which I don't think is your case), but I thought it could still apply here since the error happens during the compilation of angular core.
The suggested workaround is to run the angular compatibility compiler (ngcc) as a postinstall script, instead of having the build trigger it itself.
Modify your package.json file and add the following to the scripts section:
"postinstall": "ngcc

npm install for angular 7 app errors with: Could not find module "#angular-devkit/build-ng-packagr" from .../.npm/_cacache/tmp

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.

Hi. I am new to react and have a query re optimum setup procedures

The following package.json contains a lot of dependencies and a few devDependencies stuff but barring a few files it seems to have all I need excepting a few npm install commands for reactstrap, bootstrap, react-bootstrap
{
"name": "react-tutorials",
"version": "0.0.0",
"description": "",
"main": "webpack.config.js",
"dependencies": {
"babel-core": "^6.18.2",
"babel-loader": "^6.2.0",
"babel-plugin-add-module-exports": "^0.1.2",
"babel-plugin-react-html-attrs": "^2.0.0",
"babel-plugin-transform-class-properties": "^6.3.13",
"babel-plugin-transform-decorators-legacy": "^1.3.4",
"babel-preset-es2015": "^6.3.13",
"babel-preset-react": "^6.3.13",
"babel-preset-stage-0": "^6.3.13",
"flux": "^2.1.1",
"history": "^1.17.0",
"react": "^0.14.6",
"react-dom": "^0.14.6",
"react-router": "^1.0.3",
"webpack": "^1.12.9",
"webpack-dev-server": "^1.14.1"
},
"devDependencies": {},
"scripts": {
"dev": "webpack-dev-server --content-base src --inline --hot"
},
"author": "",
"license": "ISC"
}
// Additional dependencies and devDependencies
npm install --save reactstrap react-addons-transition-group react-addons-css-transition-group react react-dom
npm install react react-dom bootstrap react-bootstrap babel-preset-react webpack webpack-dev-server --save
npm install webpack css-loader style-loader file-loader url-loader babel-core
What is the optimal way to create a file tree for your react project via npm and what react-*** setup packages are not too difficult for a novice such as myself? Please don't suggest create-react-app - I love it but its limited. Also, can all dependencies and devDependencies be installed via npm all at once or with some files interfere with others which I've noticed before I think.
When you run each of the commands npm install --save package-here it will add that package to your package.json automatically. When you're ready to install your project from the root directory you run npm install only and it will install everything in your package.json into a node_modules folder. Other than that you should not have to change anything with your packages as far as file structure.
In addition, when you want to add a package to your dev-devependencies run npm install --save-dev or just dependencies npm install --save.

npm start giving errors on tsc && concurrently

I've been trying to run npm start and I keep getting the following errors...
19 error node v4.2.0
20 error npm v3.10.5
21 error code ELIFECYCLE
22 error resume-editor#1.0.0 start: `tsc && concurrently "npm run tsc:w" "npm run lite" `
22 error Exit status 1
23 error Failed at the resume-editor#1.0.0 start script 'tsc && concurrently "npm run tsc:w" "npm run lite" '.
23 error Make sure you have the latest version of node.js and npm installed.
23 error If you do, this is most likely a problem with the resume-editor package,
23 error not with npm itself.
23 error Tell the author that this fails on your system:
23 error tsc && concurrently "npm run tsc:w" "npm run lite"
23 error You can get information on how to open an issue for this project with:
23 error npm bugs resume-editor
23 error Or if that isn't available, you can get their info via:
23 error npm owner ls resume-editor
23 error There is likely additional logging output above.
24 verbose exit [ 1, true ]
I've tried the following:
npm install tsc (& the latest version)
npm install --save typings
typings install
npm install concurrently
npm install
npm run typings
npm run tsc (errors here)
Nothing seems to get npm start to work.
What's making this even more confusing is the fact that everything was running perfectly up until I exited out and tried to run node server.js.
Then once I tried to switch back to npm start I've been getting these errors ever since.
Package.json:
{
"name": "resume-editor",
"version": "1.0.0",
"scripts": {
"start": "tsc && concurrently \"npm run tsc:w\" \"npm run lite\" ",
"lite": "lite-server",
"postinstall": "typings install",
"tsc": "tsc",
"tsc:w": "tsc -w",
"typings": "typings"
},
"license": "ISC",
"dependencies": {
"#angular/common": "2.0.0-rc.4",
"#angular/compiler": "2.0.0-rc.4",
"#angular/core": "2.0.0-rc.4",
"#angular/forms": "0.2.0",
"#angular/http": "2.0.0-rc.4",
"#angular/platform-browser": "2.0.0-rc.4",
"#angular/platform-browser-dynamic": "2.0.0-rc.4",
"#angular/router": "3.0.0-beta.1",
"#angular/router-deprecated": "2.0.0-rc.2",
"#angular/upgrade": "2.0.0-rc.4",
"angular2-in-memory-web-api": "0.0.14",
"body-parser": "^1.4.3",
"bootstrap": "^3.3.6",
"concurrently": "^2.2.0",
"core-js": "^2.4.0",
"express": "^4.13.4",
"method-override": "^2.1.3",
"mongoose": "^4.4.12",
"morgan": "^1.1.1",
"reflect-metadata": "^0.1.3",
"rxjs": "5.0.0-beta.6",
"systemjs": "0.19.27",
"tsc": "^1.20150623.0",
"typescript": "^1.8.10",
"typings": "^1.3.2",
"zone.js": "^0.6.12"
},
"devDependencies": {
"concurrently": "^2.0.0",
"lite-server": "^2.2.0",
"typescript": "^1.8.10",
"typings": "^1.0.4"
}
}
P.S: I have the latest versions of both node and npm.
you've install a package called TSC, it's probably colliding with the command line from the typescript package tsc. Try uninstalling the TSC package and re-running
You need to install typescript globally.
npm install -g typescript
Make sure there are no spaces in the path to the root of your project. Rename ancestor directories to have no white spaces.

Resources