在最新更新后编译Angular 4软件包时遇到问题

时间:2017-10-18 10:22:32

标签: angular command-line-interface

在最新的npm更新后编译时出现问题。我删除了node_modules文件夹,运行了两次建议的npm安装。 不知道从哪里开始。一切都在100%工作,直到我不得不考虑使用要求npm更新的highcharts2。

版本。

@angular/cli: 1.4.7
node: 6.11.2
os: win32 x64
@angular/animations: 4.1.3
@angular/common: 4.1.3
@angular/compiler: 4.1.3
@angular/core: 4.1.3
@angular/forms: 4.1.3
@angular/http: 4.1.3
@angular/platform-browser: 4.1.3
@angular/platform-browser-dynamic: 4.1.3
@angular/router: 4.1.3
@angular/cli: 1.4.7
@angular/compiler-cli: 4.1.3
typescript: 2.3.3

Repro步骤。

ng build

失败给出的日志。

[D:\nodeprojects\AngularJS_4.x\full-version\src\location]
[D:\nodeprojects\AngularJS_4.x\full-version\src\location.ts]
[D:\nodeprojects\AngularJS_4.x\full-version\src\location.js]
[D:\nodeprojects\AngularJS_4.x\full-version\src\location]
[D:\nodeprojects\AngularJS_4.x\full-version\src\location]
[D:\nodeprojects\AngularJS_4.x\full-version\src\location.ts]
[D:\nodeprojects\AngularJS_4.x\full-version\src\location.js]
[D:\nodeprojects\AngularJS_4.x\full-version\src\location]
@ ./node_modules/jquery/lib/node-jquery.js 13:24-43
@ ./src/lib.ts
@ ./src/main.ts
@ multi ./src/main.ts

    *ERROR in ./node_modules/jquery/lib/node-jquery.js
    Module not found: Error: Can't resolve 'navigator' in 'D:\nodeprojects\AngularJS
    4.x\full-version\node_modules\jquery\lib'
    resolve 'navigator' in 'D:\nodeprojects\AngularJS_4.x\full-version\node_modules
    jquery\lib'
    Parsed request is a module
    using description file: D:\nodeprojects\AngularJS_4.x\full-version\node_module
    s\jquery\package.json (relative path: ./lib)
    Field 'browser' doesn't contain a valid alias configuration
    after using description file: D:\nodeprojects\AngularJS_4.x\full-version\node
    modules\jquery\package.json (relative path: ./lib)
    resolve as module
    D:\nodeprojects\AngularJS_4.x\full-version\node_modules\jquery\lib\node_mo
    dules doesn't exist or is not a directory
    D:\nodeprojects\AngularJS_4.x\full-version\node_modules\jquery\node_module
    s doesn't exist or is not a directory
    D:\nodeprojects\AngularJS_4.x\full-version\node_modules\node_modules doesn
    't exist or is not a directory
    D:\nodeprojects\AngularJS_4.x\node_modules doesn't exist or is not a direc
    tory
    D:\nodeprojects\node_modules doesn't exist or is not a directory
    D:\node_modules doesn't exist or is not a directory
    looking for modules in D:\nodeprojects\AngularJS_4.x\full-version\node_mod
    ules
    using description file: D:\nodeprojects\AngularJS_4.x\full-version\packa
    ge.json (relative path: ./node_modules)
    Field 'browser' doesn't contain a valid alias configuration
    after using description file: D:\nodeprojects\AngularJS_4.x\full-version
    \package.json (relative path: ./node_modules)
    using description file: D:\nodeprojects\AngularJS_4.x\full-version\pac
    kage.json (relative path: ./node_modules/navigator)
    no extension
    Field 'browser' doesn't contain a valid alias configuration
    D:\nodeprojects\AngularJS_4.x\full-version\node_modules\navigator
    doesn't exist
    .ts
    Field 'browser' doesn't contain a valid alias configuration
    D:\nodeprojects\AngularJS_4.x\full-version\node_modules\navigator.
    ts doesn't exist
    .js
    Field 'browser' doesn't contain a valid alias configuration
    D:\nodeprojects\AngularJS_4.x\full-version\node_modules\navigator.
    js doesn't exist
    as directory
    D:\nodeprojects\AngularJS_4.x\full-version\node_modules\navigator
    doesn't exist
    looking for modules in D:\nodeprojects\AngularJS_4.x\full-version\node_mod
    ules
    using description file: D:\nodeprojects\AngularJS_4.x\full-version\packa
    ge.json (relative path: ./node_modules)
    Field 'browser' doesn't contain a valid alias configuration
    after using description file: D:\nodeprojects\AngularJS_4.x\full-version
    \package.json (relative path: ./node_modules)
    using description file: D:\nodeprojects\AngularJS_4.x\full-version\pac
    kage.json (relative path: ./node_modules/navigator)
    no extension
    Field 'browser' doesn't contain a valid alias configuration
    D:\nodeprojects\AngularJS_4.x\full-version\node_modules\navigator
    doesn't exist
    .ts
    Field 'browser' doesn't contain a valid alias configuration
    D:\nodeprojects\AngularJS_4.x\full-version\node_modules\navigator.
    ts doesn't exist
    .js
    Field 'browser' doesn't contain a valid alias configuration
    D:\nodeprojects\AngularJS_4.x\full-version\node_modules\navigator.
    js doesn't exist
    as directory
    D:\nodeprojects\AngularJS_4.x\full-version\node_modules\navigator
    doesn't exist
    looking for modules in D:\nodeprojects\AngularJS_4.x\full-version\src
    using description file: D:\nodeprojects\AngularJS_4.x\full-version\packa
    ge.json (relative path: ./src)
    Field 'browser' doesn't contain a valid alias configuration
    after using description file: D:\nodeprojects\AngularJS_4.x\full-version
    \package.json (relative path: ./src)
    using description file: D:\nodeprojects\AngularJS_4.x\full-version\pac
    kage.json (relative path: ./src/navigator)
    no extension
    Field 'browser' doesn't contain a valid alias configuration
    D:\nodeprojects\AngularJS_4.x\full-version\src\navigator doesn't e
    xist
    .ts
    Field 'browser' doesn't contain a valid alias configuration
    D:\nodeprojects\AngularJS_4.x\full-version\src\navigator.ts doesn'
    t exist
    .js
    Field 'browser' doesn't contain a valid alias configuration
    D:\nodeprojects\AngularJS_4.x\full-version\src\navigator.js doesn'
    t exist
    as directory
    D:\nodeprojects\AngularJS_4.x\full-version\src\navigator doesn't e
    xist
    looking for modules in D:\nodeprojects\AngularJS_4.x\full-version\src
    using description file: D:\nodeprojects\AngularJS_4.x\full-version\packa
    ge.json (relative path: ./src)
    Field 'browser' doesn't contain a valid alias configuration
    after using description file: D:\nodeprojects\AngularJS_4.x\full-version
    \package.json (relative path: ./src)
    using description file: D:\nodeprojects\AngularJS_4.x\full-version\pac
    kage.json (relative path: ./src/navigator)
    no extension
    Field 'browser' doesn't contain a valid alias configuration
    D:\nodeprojects\AngularJS_4.x\full-version\src\navigator doesn't e
    xist
    .ts
    Field 'browser' doesn't contain a valid alias configuration
    D:\nodeprojects\AngularJS_4.x\full-version\src\navigator.ts doesn'
    t exist
    .js
    Field 'browser' doesn't contain a valid alias configuration
    D:\nodeprojects\AngularJS_4.x\full-version\src\navigator.js doesn'
    t exist
    as directory
    D:\nodeprojects\AngularJS_4.x\full-version\src\navigator doesn't e
    xist
    [D:\nodeprojects\AngularJS_4.x\full-version\node_modules\jquery\lib\node_modules
    ]
    [D:\nodeprojects\AngularJS_4.x\full-version\node_modules\jquery\node_modules]
    [D:\nodeprojects\AngularJS_4.x\full-version\node_modules\node_modules]
    [D:\nodeprojects\AngularJS_4.x\node_modules]
    [D:\nodeprojects\node_modules]
    [D:\node_modules]
    [D:\nodeprojects\AngularJS_4.x\full-version\node_modules\navigator]
    [D:\nodeprojects\AngularJS_4.x\full-version\node_modules\navigator.ts]
    [D:\nodeprojects\AngularJS_4.x\full-version\node_modules\navigator.js]
    [D:\nodeprojects\AngularJS_4.x\full-version\node_modules\navigator]
    [D:\nodeprojects\AngularJS_4.x\full-version\node_modules\navigator]
    [D:\nodeprojects\AngularJS_4.x\full-version\node_modules\navigator.ts]
    [D:\nodeprojects\AngularJS_4.x\full-version\node_modules\navigator.js]
    [D:\nodeprojects\AngularJS_4.x\full-version\node_modules\navigator]
    [D:\nodeprojects\AngularJS_4.x\full-version\src\navigator]
    [D:\nodeprojects\AngularJS_4.x\full-version\src\navigator.ts]
    [D:\nodeprojects\AngularJS_4.x\full-version\src\navigator.js]
    [D:\nodeprojects\AngularJS_4.x\full-version\src\navigator]
    [D:\nodeprojects\AngularJS_4.x\full-version\src\navigator]
    [D:\nodeprojects\AngularJS_4.x\full-version\src\navigator.ts]
    [D:\nodeprojects\AngularJS_4.x\full-version\src\navigator.js]
    [D:\nodeprojects\AngularJS_4.x\full-version\src\navigator]*

@ ./node_modules/jquery/lib/node-jquery.js 17:25-45
@ ./src/lib.ts
@ ./src/main.ts
@ multi ./src/main.ts

    ERROR in ./node_modules/jquery/lib/node-jquery.js
    Module not found: Error: Can't resolve 'xmlhttprequest' in 'D:\nodeprojects\Angu
    larJS_4.x\full-version\node_modules\jquery\lib'
    resolve 'xmlhttprequest' in 'D:\nodeprojects\AngularJS_4.x\full-version\node_mod
    ules\jquery\lib'
    Parsed request is a module
    using description file: D:\nodeprojects\AngularJS_4.x\full-version\node_module
    s\jquery\package.json (relative path: ./lib)
    Field 'browser' doesn't contain a valid alias configuration
    after using description file: D:\nodeprojects\AngularJS_4.x\full-version\node_
    modules\jquery\package.json (relative path: ./lib)
    resolve as module
    D:\nodeprojects\AngularJS_4.x\full-version\node_modules\jquery\lib\node_mo
    dules doesn't exist or is not a directory
    D:\nodeprojects\AngularJS_4.x\full-version\node_modules\jquery\node_module
    s doesn't exist or is not a directory
    D:\nodeprojects\AngularJS_4.x\full-version\node_modules\node_modules doesn
    't exist or is not a directory
    D:\nodeprojects\AngularJS_4.x\node_modules doesn't exist or is not a direc
    tory
    D:\nodeprojects\node_modules doesn't exist or is not a directory
    D:\node_modules doesn't exist or is not a directory
    looking for modules in D:\nodeprojects\AngularJS_4.x\full-version\node_mod
    ules
    using description file: D:\nodeprojects\AngularJS_4.x\full-version\packa
    ge.json (relative path: ./node_modules)
    Field 'browser' doesn't contain a valid alias configuration
    after using description file: D:\nodeprojects\AngularJS_4.x\full-version
    \package.json (relative path: ./node_modules)
    using description file: D:\nodeprojects\AngularJS_4.x\full-version\pac
    kage.json (relative path: ./node_modules/xmlhttprequest)
    no extension
    Field 'browser' doesn't contain a valid alias configuration
    D:\nodeprojects\AngularJS_4.x\full-version\node_modules\xmlhttpreq
    uest doesn't exist
    .ts
    Field 'browser' doesn't contain a valid alias configuration
    D:\nodeprojects\AngularJS_4.x\full-version\node_modules\xmlhttpreq
    uest.ts doesn't exist
    .js
    Field 'browser' doesn't contain a valid alias configuration
    D:\nodeprojects\AngularJS_4.x\full-version\node_modules\xmlhttpreq
    uest.js doesn't exist
    as directory
    D:\nodeprojects\AngularJS_4.x\full-version\node_modules\xmlhttpreq
    uest doesn't exist
    looking for modules in D:\nodeprojects\AngularJS_4.x\full-version\node_mod
    ules
    using description file: D:\nodeprojects\AngularJS_4.x\full-version\packa
    ge.json (relative path: ./node_modules)
    Field 'browser' doesn't contain a valid alias configuration
    after using description file: D:\nodeprojects\AngularJS_4.x\full-version
    \package.json (relative path: ./node_modules)
    using description file: D:\nodeprojects\AngularJS_4.x\full-version\pac
    kage.json (relative path: ./node_modules/xmlhttprequest)
    no extension
    Field 'browser' doesn't contain a valid alias configuration
    D:\nodeprojects\AngularJS_4.x\full-version\node_modules\xmlhttpreq
    uest doesn't exist
    .ts
    Field 'browser' doesn't contain a valid alias configuration
    D:\nodeprojects\AngularJS_4.x\full-version\node_modules\xmlhttpreq
    uest.ts doesn't exist
    .js
    Field 'browser' doesn't contain a valid alias configuration
    D:\nodeprojects\AngularJS_4.x\full-version\node_modules\xmlhttpreq
    uest.js doesn't exist
    as directory
    D:\nodeprojects\AngularJS_4.x\full-version\node_modules\xmlhttpreq
    uest doesn't exist
    looking for modules in D:\nodeprojects\AngularJS_4.x\full-version\src
    using description file: D:\nodeprojects\AngularJS_4.x\full-version\packa
    ge.json (relative path: ./src)
    Field 'browser' doesn't contain a valid alias configuration
    after using description file: D:\nodeprojects\AngularJS_4.x\full-version
    \package.json (relative path: ./src)
    using description file: D:\nodeprojects\AngularJS_4.x\full-version\pac
    kage.json (relative path: ./src/xmlhttprequest)
    no extension
    Field 'browser' doesn't contain a valid alias configuration
    D:\nodeprojects\AngularJS_4.x\full-version\src\xmlhttprequest does
    n't exist
    .ts
    Field 'browser' doesn't contain a valid alias configuration
    D:\nodeprojects\AngularJS_4.x\full-version\src\xmlhttprequest.ts d
    oesn't exist
    .js
    Field 'browser' doesn't contain a valid alias configuration
    D:\nodeprojects\AngularJS_4.x\full-version\src\xmlhttprequest.js d
    oesn't exist
    as directory
    D:\nodeprojects\AngularJS_4.x\full-version\src\xmlhttprequest does
    n't exist
    looking for modules in D:\nodeprojects\AngularJS_4.x\full-version\src
    using description file: D:\nodeprojects\AngularJS_4.x\full-version\packa
    ge.json (relative path: ./src)
    Field 'browser' doesn't contain a valid alias configuration
    after using description file: D:\nodeprojects\AngularJS_4.x\full-version
    \package.json (relative path: ./src)
    using description file: D:\nodeprojects\AngularJS_4.x\full-version\pac
    kage.json (relative path: ./src/xmlhttprequest)
    no extension
    Field 'browser' doesn't contain a valid alias configuration
    D:\nodeprojects\AngularJS_4.x\full-version\src\xmlhttprequest does
    n't exist
    .ts
    Field 'browser' doesn't contain a valid alias configuration
    D:\nodeprojects\AngularJS_4.x\full-version\src\xmlhttprequest.ts d
    oesn't exist
    .js
    Field 'browser' doesn't contain a valid alias configuration
    D:\nodeprojects\AngularJS_4.x\full-version\src\xmlhttprequest.js d
    oesn't exist
    as directory
    D:\nodeprojects\AngularJS_4.x\full-version\src\xmlhttprequest does
    n't exist
    [D:\nodeprojects\AngularJS_4.x\full-version\node_modules\jquery\lib\node_modules
    ]
    [D:\nodeprojects\AngularJS_4.x\full-version\node_modules\jquery\node_modules]
    [D:\nodeprojects\AngularJS_4.x\full-version\node_modules\node_modules]
    [D:\nodeprojects\AngularJS_4.x\node_modules]
    [D:\nodeprojects\node_modules]
    [D:\node_modules]
    [D:\nodeprojects\AngularJS_4.x\full-version\node_modules\xmlhttprequest]
    [D:\nodeprojects\AngularJS_4.x\full-version\node_modules\xmlhttprequest.ts]
    [D:\nodeprojects\AngularJS_4.x\full-version\node_modules\xmlhttprequest.js]
    [D:\nodeprojects\AngularJS_4.x\full-version\node_modules\xmlhttprequest]
    [D:\nodeprojects\AngularJS_4.x\full-version\node_modules\xmlhttprequest]
    [D:\nodeprojects\AngularJS_4.x\full-version\node_modules\xmlhttprequest.ts]
    [D:\nodeprojects\AngularJS_4.x\full-version\node_modules\xmlhttprequest.js]
    [D:\nodeprojects\AngularJS_4.x\full-version\node_modules\xmlhttprequest]
    [D:\nodeprojects\AngularJS_4.x\full-version\src\xmlhttprequest]
    [D:\nodeprojects\AngularJS_4.x\full-version\src\xmlhttprequest.ts]
    [D:\nodeprojects\AngularJS_4.x\full-version\src\xmlhttprequest.js]
    [D:\nodeprojects\AngularJS_4.x\full-version\src\xmlhttprequest]
    [D:\nodeprojects\AngularJS_4.x\full-version\src\xmlhttprequest]
    [D:\nodeprojects\AngularJS_4.x\full-version\src\xmlhttprequest.ts]
    [D:\nodeprojects\AngularJS_4.x\full-version\src\xmlhttprequest.js]
    [D:\nodeprojects\AngularJS_4.x\full-version\src\xmlhttprequest]

@ ./node_modules/jquery/lib/node-jquery.js 8:28-53
@ ./src/lib.ts
@ ./src/main.ts
@ multi ./src/main.ts

所需的功能。

提及可能有用的任何其他详细信息。

我们正在使用Smartadmin Angular 4.0软件包

的package.json:

{
  "name": "smartadmin",
  "version": "0.4.5",
  "license": "WRAPBOOTSTRAP",
  "angular-cli": {},
  "scripts": {
    "build:dev": "./node_modules/.bin/ng build",
    "build:prod": "./node_modules/.bin/ng build --prod --aot=false",
    "build:aot": "./node_modules/.bin/ng build --prod --aot",
    "build:aot2": "node --max_old_space_size=4096 ./node_modules/.bin/ng build --prod --aot",
    "build": "npm run build:dev",
    "clean:dist": "npm run rimraf -- dist",
    "clean:install": "npm set progress=false && npm install",
    "clean:start": "npm start",
    "clean": "npm cache clean && npm run rimraf -- node_modules doc coverage dist",
    "e2e:live": "npm run e2e -- --elementExplorer",
    "e2e": "npm run protractor",
    "lint": "npm run tslint \"src/**/*.ts\"",
    "postversion": "git push && git push --tags",
    "prebuild:dev": "npm run clean:dist",
    "prebuild:prod": "npm run clean:dist",
    "preclean:install": "npm run clean",
    "preclean:start": "npm run clean",
    "preversion": "npm test",
    "protractor": "protractor",
    "rimraf": "rimraf",
    "server:dev": "./node_modules/.bin/ng serve",
    "server": "npm run server:dev",
    "start": "npm run server:dev",
    "test": "./node_modules/.bin/ng test",
    "tslint": "tslint",
    "typedoc": "typedoc",
    "version": "npm run build",
    "ng": "ng",
    "pree2e": "webdriver-manager update --standalone false --gecko false"
  },
  "private": true,
  "dependencies": {
    "@angular-redux/store": "6.3.0",
    "@angular/animations": "4.1.3",
    "@angular/common": "4.1.3",
    "@angular/compiler": "4.1.3",
    "@angular/core": "4.1.3",
    "@angular/forms": "4.1.3",
    "@angular/http": "4.1.3",
    "@angular/platform-browser": "4.1.3",
    "@angular/platform-browser-dynamic": "4.1.3",
    "@angular/router": "4.1.3",
    "X-editable": "github:vitalets/x-editable",
    "bootstrap": "3.3.7",
    "bootstrap-colorpicker": "2.5.1",
    "bootstrap-duallistbox": "3.0.6",
    "bootstrap-markdown": "2.10.0",
    "bootstrap-progressbar": "0.9.0",
    "bootstrap-slider": "9.8.0",
    "bootstrap-tagsinput": "0.7.1",
    "bootstrap-timepicker": "0.5.2",
    "chart.js": "2.6.0",
    "classlist.js": "^1.1.20150312",
    "clockpicker": "0.0.7",
    "clone": "2.1.1",
    "core-js": "2.4.1",
    "debounce": "1.0.2",
    "dropzone": "4.3.0",
    "dygraphs": "2.0.0",
    "fuelux": "3.16.0",
    "he": "1.1.1",
    "highcharts": "5.0.12",
    "ion-rangeslider": "2.1.7",
    "jquery": "2.2.4",
    "jquery-color": "1.0.0",
    "jquery-jcrop": "0.9.13",
    "jquery-knob": "1.2.11",
    "jquery-ui-npm": "1.12.0",
    "jquery-validation": "1.16.0",
    "jquery.maskedinput": "1.4.1",
    "markdown": "0.5.0",
    "morris.js": "0.5.0",
    "ngx-bootstrap": "^2.0.0-beta.2",
    "ngx-popover": "0.0.16",
    "nouislider": "9.2.0",
    "raphael": "2.2.7",
    "redux": "3.6.0",
    "rxjs": "5.4.0",
    "scriptjs": "2.5.8",
    "select2": "4.0.3",
    "smartadmin-plugins": "1.0.20",
    "summernote": "0.8.3",
    "to-markdown": "3.0.4",
    "ts-helpers": "1.1.2",
    "web-animations-js": "2.2.5",
    "zone.js": "0.8.11"
  },
  "devDependencies": {
    "@angular/cli": "1.0.6",
    "@angular/compiler-cli": "4.1.3",
    "@types/jasmine": "2.5.47",
    "@types/jquery": "2.0.45",
    "@types/node": "7.0.22",
    "codelyzer": "3.0.1",
    "jasmine-core": "2.6.2",
    "jasmine-spec-reporter": "4.1.0",
    "karma": "1.7.0",
    "karma-chrome-launcher": "2.1.1",
    "karma-cli": "1.0.1",
    "karma-jasmine": "1.1.0",
    "karma-jasmine-html-reporter": "0.2.2",
    "karma-coverage-istanbul-reporter": "1.2.1",
    "protractor": "5.1.2",
    "ts-node": "3.0.4",
    "tslint": "5.3.2",
    "typescript": "2.3.3",
    "css-loader": "0.28.3",
    "exports-loader": "0.6.4",
    "expose-loader": "0.7.3",
    "file-loader": "0.11.1",
    "imports-loader": "0.7.1",
    "karma-remap-istanbul": "0.6.0",
    "raw-loader": "0.5.1",
    "script-loader": "0.7.0",
    "style-loader": "0.18.1",
    "url-loader": "0.5.8"
  },
  "repository": {
    "type": "git",
    "url": "https://bitbucket.org/grigson/smartadmin-angular-2"
  },
  "bugs": {
    "url": "https://bitbucket.org/grigson/smartadmin-angular-2/issues"
  },
  "engines": {
    "node": ">= 4.2.1",
    "npm": ">= 3"
  }
}

1 个答案:

答案 0 :(得分:1)

在我看来,缺少必需的npm软件包 xmlhttprequest 导航器

您应该可以通过以下方式解决此问题:

npm install --save xmlhttprequest navigator

原因似乎是此应用程序使用的过时jQuery包,它依赖于这些浏览器内置对象,但没有将它们列为依赖项。