I executed a update to angular 6. And during ng serve -o I receive error that sass-loader expect node-sass.
After run ng serve -o I receive:
ERROR in ./src/sass/styles.scss (./node_modules/raw-loader!./node_modules/postcss-loader/lib??embedded!./node_modules/sass-loader/lib/loader.js??ref--14-3!./src/sass/styles.scss)
Module build failed: Error: `sass-loader` requires `node-sass` >=4. Please install a compatible version.
at Object.sassLoader (node_modules\sass-loader\lib\loader.js:31:19)
ERROR in ./src/app/app.component.scss
Module build failed: Error: `sass-loader` requires `node-sass` >=4. Please install a compatible version.
at Object.sassLoader (node_modules\sass-loader\lib\loader.js:31:19)
ERROR in x.component.scss
Module build failed: Error: `sass-loader` requires `node-sass` >=4. Please install a compatible version.
at Object.sassLoader (\node_modules\sass-loader\lib\loader.js:31:19)
ERROR in x.component.scss
Module build failed: Error: `sass-loader` requires `node-sass` >=4. Please install a compatible version.
at Object.sassLoader (loader.js:31:19)
ERROR in .x.component.scss
Module build failed: Error: `sass-loader` requires `node-sass` >=4. Please install a compatible version.
at Object.sassLoader (node_modules\sass-loader\lib\loader.js:31:19)
Obvisously I check everything (in my opinion) and I don't have idea what's going on.
Package.Json:
"devDependencies": {
"#angular-devkit/build-angular": "~0.6.0",
"#angular/cli": "6.0.0",
"#angular/compiler-cli": "6.0.0",
"#angular/language-service": "6.0.0",
"#types/jasmine": "~2.8.3",
"#types/jasminewd2": "~2.0.2",
"#types/node": "~6.0.106",
"codelyzer": "^4.0.1",
"jasmine-core": "~2.8.0",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~2.0.0",
"karma-chrome-launcher": "~2.2.0",
"karma-html-detailed-reporter": "^1.1.21",
"karma-jasmine": "~1.1.0",
"karma-jasmine-html-reporter": "^0.2.2",
"karma-phantomjs-launcher": "^1.0.4",
"karma-teamcity-reporter": "^1.1.0",
"phantomjs-prebuilt": "^2.1.16",
"protractor": "~5.1.2",
"node-sass": "^4.9.0",
"sass-loader": "^7.0.1",
"ts-node": "~4.1.0",
"tslint": "~5.9.1",
"typescript": "2.7.2"
}
dir -l node_modules says:
...
05/07/2018 08:53 AM <DIR> node-sass
...
05/07/2018 08:53 AM <DIR> sass-loader
...
I executed:
npm rebuild node-sass
and secod approach:
I removed local node-module together with %User%\AppData\Roaming\npm-cache. then I removed lock file and execuded npm
npm cache clear --force
npm install
But still no success.
What do I miss ?
npm rebuild --force
aslo helps
I fixed it with
npm install node-sass
inside the project folder, and for the project, because installing it globally (with the -g option) didn't solve the issue.
I had same issue which I fixed using following steps:
Delete package-lock.json file.
Go to node_module folder and run rm -rf node_modules.
Run npm install
The package-lock.json file will auto-update with the new dependencies version.
hope it helps.
I fixed this issue using below steps:
Open package.json
Add which version you want to install of node-sass, for example "node-sass": "^4.12.0"
Run the installation command in command line interface (CLI): npm install node-sass
The issue will get resolved.
Simply run this code...
npm install --save node-sass
To solve your issue run this command
npm install --unsafe-perm
Following steps solved this issue
Delete node-saas folder in \Users\<user_id>\AppData\Roaming\npm-cache
Delete node-saas folder in <application_folder>/node_modules
Run npm install from <application_folder>
It could probably be a version mismatch. To install the working node-sass version, you can use
npm uninstall node-sass
npm install node-sass#4.14.0
And you can choose your version number based on the following table, and the node version you have installed, which you can check by node --version
You can find full info here
This has solved my issue
You can follow these steps:
First of all Delete package-lock.json file and node_modules.
and then Run npm install
The package-lock.json file will auto-update with the new dependencies version.
Related
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.
On a Gatsby 2.17.6 project, when building:
Building production JavaScript and CSS bundles [====
] 1.940 s 1/6 17% run queries failed Building production JavaScript
and CSS bundles - 75.519s
ERROR #98123 WEBPACK
Generating JavaScript bundles failed
postcss-svgo: TypeError: Cannot set property 'multipassCount' of
undefined
not finished run queries - 77.639s npm ERR! code ELIFECYCLE npm ERR!
errno 1 npm ERR! gatsby-starter-default#1.0.0 build: node
node_modules/gatsby/dist/bin/gatsby.js build` npm ERR! Exit status 1
These are some of my dependencies:
"dependencies": {
"babel-plugin-styled-components": "^1.8.0",
:
"gatsby": "^2.0.19",
"gatsby-plugin-favicon": "^3.1.4",
"gatsby-plugin-google-fonts": "0.0.4",
"gatsby-plugin-offline": "^2.0.5",
"gatsby-plugin-react-helmet": "^3.0.0",
"gatsby-plugin-styled-components": "^3.0.1",
:
"react": "^16.5.1",
"react-dom": "^16.5.1",
"react-helmet": "^5.2.0",
"react-leaflet": "^2.1.1",
"styled-components": "^4.1.1"
}
I don't see any configurations about postcss on gatsby-config.js, I guess it's a default behaviour of Gatsby. npm ls postcss-svgo throw this:
gatsby-starter-default#1.0.0 /<app>/source
└─┬ gatsby#2.17.6
└─┬ optimize-css-assets-webpack-plugin#5.0.3
└─┬ cssnano#4.1.10
└─┬ cssnano-preset-default#4.0.7
└── postcss-svgo#4.0.2
I wouldn't mind to disable postcss-svgo if that's a solution, but I don't know how.
my project is solved, use npm install svgo#1.3.0 -E, detail see: https://github.com/svg/svgo/issues/1174
"resolutions": { "svgo": "1.3.0" }
Add the above to your "package.json" and then rm -rf node_modules to remove "node_modules" and then reinstall "node_modules" again.
This will resolve issue.
This issue is related to latest version of postcss-svgo.
Version 1.3.2 of svgo has been released, and this bug is suposed to be fixed
So, it would be enough to remove your node_modules dir and package-lock.json file, and make a new npm install or yarn install
Anyway, thanks to other users suggesting to rollback svgo to 1.3.0
It works.
$ npm install -g svgo
remove node_modules and package-lock.json
$ npm install
build project
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.
I have package.json file, that contains 10 dependencies,
Every time I do npm install -g,all the dependencies are downloaded again, and this takes a long time.
Is there a way to take the existing dependencies from the local node_modules directory ?
This is my package.json dependencies:
"dependencies": {
"body-parser": "~1.16.0",
"colors": "^1.1.2",
"console-stamp": "^0.2.5",
"cookie-parser": "~1.4.3",
"dateformat": "^2.0.0",
"debug": "~2.6.0",
"express": "~4.14.1",
"ip": "^1.1.5",
"jade": "~1.11.0",
"lodash": "^4.17.4",
"morgan": "~1.7.0",
"nodemon": "^1.11.0",
"promise": "^8.0.1",
"rand-token": "^0.3.0",
"random-date-generator": "^1.0.2",
"restify": "^4.3.0",
"restify-cookies": "^0.2.2",
"serve-favicon": "~2.3.2"
}
Thanks,
npm install -g installs the current package context (i.e, the current working directory) as a global package. You do not need this for installing the project dependencies. Instead you can use npm install which will install/update dependencies in node_modules folder. By default, npm install will install all modules listed as dependencies in package.json and they do not install all dependencies every time and will only update when a change has been made to package.json or the node_modules folder is cleared out.
use npm install -g option to install packages globally like cordova, gulp, yeoman etc where you need them to be available throughout multiple projects.
Conceptually, the input to npm-install is a package.json, while its output is a fully-formed node_modules tree.
This shouldn't be an issue because npm uses the cache. It returns 304 if you have already installed the module, you can check it by applying --verbose with npm install command if given it's the same version of the dependency.
What I mean is:
$ npm install express
npm http fetch GET http://registry.npmjs.org/express
npm http fetch GET 200 http://registry.npmjs.org/express
at last, it shows:
++ express#4.16.2
added 49 packages in 12.547s
If you run it again then you will see
$ npm install express
npm http fetch GET http://registry.npmjs.org/express 408ms (from cache)
npm http fetch GET 304 http://registry.npmjs.org/express 408ms (from cache)
at last, it shows:
skipping write for package.json because there were no changes
++ express#4.16.2
updated 1 package in 4.11s
It hits the cache and won't download it again.
When running npm install for a second time on a project then it will not download it again only npm will check the first level of modules to ensure they're installed.
but not traverse the dependency tree to ensure all sub-module dependencies are installed. You can run npm outdated to check if modules are missing but npm won't install them for you.
npm update express updates the express module and its dependencies. So updates are when you already have the module and wish to get the new version. the update will always update to the latest version, regardless of package.json, while npm install will respect the version given in package.json.
I am having issues with my package.json file.
It should work fine as as I use most of the node modules in other projects, but I have this package.json below:
"dependencies": {
"#angular/common": "^2.0.0-rc.1",
"#angular/compiler": "^2.0.0-rc.1",
"#angular/core": "^2.0.0-rc.1",
"#angular/platform-browser": "^2.0.0-rc.1",
"#angular/platform-browser-dynamic": "^2.0.0-rc.1",
"#angular/router": "^2.0.0-rc.1",
"angular2-in-memory-web-api": "0.0.7",
"bootstrap": "^3.3.6",
"es6-shim": "^0.35.0",
"reflect-metadata": "^0.1.3",
"rxjs": "^5.0.0-beta.6",
"systemjs": "^0.19.27",
"zone.js": "^0.6.12"
},
"devDependencies": {
"body-parser": "^1.15.1",
"express": "^4.13.4",
"jsonwebtoken": "^6.2.0",
"mongoose": "^4.4.15"
}
and they should all run fine as all dependencies exist as angular is now in rc.4 and rxjs is on 5.0.0-beta.10.
But I get 3 unmet dependencies on
npm install
'rxjs#5.0.0-beta.10'
'rxjs#5.0.0-beta.6'
'#angular/core#2.0.0-rc.1'
I get these warnings too:
npm WARN #angular/core#2.0.0-rc.4 requires a peer of rxjs#5.0.0-beta.6 but none was installed.
npm WARN #angular/http#2.0.0-rc.1 requires a peer of rxjs#5.0.0-beta.6 but none was installed.
npm WARN #angular/http#2.0.0-rc.1 requires a peer of #angular/core#2.0.0-rc.1 but none was installed.
I have also done:
npm cache clean
npm update registry > with the registry link
npm update -g
node is on latest version and still same issue... so just wondering if there is something wrong?
I think its because the dependency resolution is a bit broken, see https://github.com/isaacs/npm/issues/1341#issuecomment-20634338
You may need to manually install top-level modules that have unmet dependencies:
npm install findup-sync#0.1.2
Or structure your package.json such that any top-level modules that are also dependencies of other modules are listed lower down.
Your problem could also be that npm failed to download the package, timed-out or whatnot. Sometimes re-running npm install remedies it.
You can also install the failed packages manually as well using npm install
Other steps that may help before attempting npm install again are:
Removing node_modules using:
rm -rf node_modules/
then
npm cache clean
To explain why removing node_modules sometimes is necessary:
Apparently if a nested module fails to install during npm install, subsequent npm install won't detect those missing nested dependencies. If that's the case, sometimes it's sufficient to remove the top-level dependency of those missing nested modules, and running npm install again.
See https://github.com/npm/npm/issues/1336