Can't install dependencies via npm in Angular

2019-09-19 06:45发布

I have downloaded Angular 2 from main site (quickproject) but I have a lot of problems with install additional libraries. When, for example I try to install angular2-modal module I get:

 npm install angular2-modal --save
angular-quickstart@1.0.0 C:\WebServ\httpd\quickstart
`-- angular2-modal@2.0.2

npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.0.0 (node_modules\chokidar\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.0.17: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN @angular/upgrade@2.2.4 requires a peer of @angular/core@2.2.4 but none was installed.
npm WARN @angular/upgrade@2.2.4 requires a peer of @angular/compiler@2.2.4 but none was installed.
npm WARN @angular/upgrade@2.2.4 requires a peer of @angular/platform-browser@2.2.4 but none was installed.
npm WARN @angular/upgrade@2.2.4 requires a peer of @angular/platform-browser-dynamic@2.2.4 but none was installed.

I cannot install anything because of this fsevents I think. When I tried to do

npm update 

I received

npm update --save
npm ERR! Windows_NT 6.1.7601
npm ERR! argv "D:\\Program Files\\nodejs\\node.exe" "D:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "update" "--save"
npm ERR! node v6.9.2
npm ERR! npm  v3.10.9
npm ERR! code EBADPLATFORM

npm ERR! notsup Unsupported platform for fsevents@1.0.17: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm ERR! notsup Valid OS:    darwin
npm ERR! notsup Valid Arch:  any
npm ERR! notsup Actual OS:   win32
npm ERR! notsup Actual Arch: x64

npm ERR! Please include the following file with any support request:
npm ERR!     C:\WebServ\httpd\quickstart\npm-debug.log

How to repair it?

{


"name": "angular-quickstart",
  "version": "1.0.0",
  "description": "QuickStart package.json from the documentation, supplemented with testing support",
  "scripts": {
    "start": "tsc && concurrently \"tsc -w\" \"lite-server\" ",
    "e2e": "tsc && concurrently \"http-server -s\" \"protractor protractor.config.js\" --kill-others --success first",
    "lint": "tslint ./app/**/*.ts -t verbose",
    "lite": "lite-server",
    "pree2e": "webdriver-manager update",
    "test": "tsc && concurrently \"tsc -w\" \"karma start karma.conf.js\"",
    "test-once": "tsc && karma start karma.conf.js --single-run",
    "tsc": "tsc",
    "tsc:w": "tsc -w"
  },
  "keywords": [],
  "author": "",
  "license": "MIT",
  "dependencies": {
    "@angular/common": "^2.4.3",
    "@angular/compiler": "^2.4.3",
    "@angular/core": "^2.4.3",
    "@angular/forms": "^2.4.3",
    "@angular/http": "^2.4.3",
    "@angular/platform-browser": "^2.4.3",
    "@angular/platform-browser-dynamic": "^2.4.3",
    "@angular/router": "^3.4.3",
    "@angular/upgrade": "^2.2.4",
    "@swimlane/ngx-datatable": "^5.0.0",
    "@types/jasmine": "^2.5.41",
    "@types/node": "^6.0.60",
    "angular-datatables": "^2.0.1",
    "angular-in-memory-web-api": "~0.2.4",
    "angular2-datatable": "^0.5.2",
    "fsevents": "^1.0.0",
    "angular2-modal": "^2.0.2",
    "core-js": "^2.4.1",
    "datatables.net": "^2.1.1",
    "datatables.net-dt": "^2.1.1",
    "jquery": "^3.1.1",
    "karma": "^1.4.0",
    "rxjs": "^5.0.3",
    "systemjs": "0.19.40",
    "zone.js": "^0.7.6"
  },
  "devDependencies": {
    "concurrently": "^3.1.0",
    "lite-server": "^2.2.2",
    "typescript": "~2.0.10",
    "canonical-path": "0.0.2",
    "http-server": "^0.9.0",
    "tslint": "^3.15.1",
    "lodash": "^4.16.4",
    "jasmine-core": "~2.4.1",
    "karma": "^1.3.0",
    "karma-chrome-launcher": "^2.0.0",
    "karma-cli": "^1.0.1",
    "karma-jasmine": "^1.0.2",
    "karma-jasmine-html-reporter": "^0.2.2",
    "protractor": "~4.0.14",
    "rimraf": "^2.5.4",
    "@types/node": "^6.0.46",
    "@types/jasmine": "^2.5.36"
  },
  "repository": {}
}

3条回答
可以哭但决不认输i
2楼-- · 2019-09-19 07:22

fsevents is an OS X specific API that handles file notification events better on that operating system. Since you are on Windows, you can't run fsevents. It's OS X only.

The npm WARN messages you get are just warnings. It's skipping the optional fsevents dependency that you can't install on your OS. Some of the other warnings you get are a version mismatch between the Angular2 you want to install (2.4.3) and the one that angular2-modal wants as a peer (2.2.4), but this should probably work okay.

Remove fsevents from package.json. Some other dependencies may try to install it on OS X, but you don't need to include it as a core dependency of your project.

查看更多
Luminary・发光体
3楼-- · 2019-09-19 07:24

Delete everything from node_modules. run "npm install" from terminal. then try to run "npm start". Make sure you have installed latest version of node & npm

查看更多
We Are One
4楼-- · 2019-09-19 07:30

Simple steps for downloading working Angular2 via NPM

  1. Install NPM into your system
  2. Install node.js into your system
  3. Now follow follwing steps :-

Note :- For install Angular2 CLI globally Command : npm install -g @angular/cli

Step.1 npm install --save-dev @angular/cli@latest ( install angular dependencies )

Step.2 ng new my-app ( Creating New Angular2 Project )

Step.3 cd my-app ( Comes to your project path )

Step.4 ng serve --open ( This command is for launching the server )

Open Your Angular2 project :- http://localhost:4200/

查看更多
登录 后发表回答