angular2,typescript peer无效,无法导入模块

时间:2016-09-05 10:45:49

标签: javascript node.js angular typescript

我有两个问题,可能是它相互依赖:

  1. 我不能要求/导入sass@0.5.0
  2. 打字稿有效,但我看错了
  3. 通过命令npm list:

    ├── sass@0.5.0 extraneous
    ├── systemjs@0.19.27
    ├── typescript@1.8.10 peer invalid
    ├── typings@1.3.3
    └── zone.js@0.6.17
    
    npm ERR! extraneous: sass@0.5.0 C:\Users\AxOn\Documents\projects\NODETS+ANGULAR2\public\node_modules\sass
    npm ERR! peer invalid: typescript@1.8.10 C:\Users\AxOn\Documents\projects\NODETS+ANGULAR2\public\node_modules\typescript
    

    可能,因为typescript@1.8.10对等无效,我看不到模块:

    从'sass'导入{sass}; //错误

    C:\Users\AxOn\Documents\projects\NODETS+ANGULAR2\public>npm install sass --save
    npm WARN package.json angular2-quickstart@1.0.0 No description
    npm WARN package.json angular2-quickstart@1.0.0 No repository field.
    npm WARN package.json angular2-quickstart@1.0.0 No README data
    npm WARN excluding symbolic link index.js -> lib/sass.js
    npm WARN excluding symbolic link lib\index.js -> sass.js
    npm WARN unmet dependency C:\Users\AxOn\Documents\projects\NODETS+ANGULAR2\public\node_modules\lite-server\node_modules\browser-sync\node_modules\socket.io\node_modules\socket.io-client\node_modules\engine.io-client requires component-emitter@'1.1.2' but will load
    
    npm WARN unmet dependency C:\Users\AxOn\Documents\projects\NODETS+ANGULAR2\public\node_modules\lite-server\node_modules\browser-sync\node_modules\socket.io\node_modules\socket.io-client\node_modules\component-emitter,
    npm WARN unmet dependency which is version 1.2.0
    npm ERR! Windows_NT 10.0.10586
    npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "sass" "--save"
    npm ERR! node v4.2.6
    npm ERR! npm  v2.14.12
    npm ERR! code EPEERINVALID
    
    npm ERR! peerinvalid The package typescript@1.8.10 does not satisfy its siblings' peerDependencies requirements!
    npm ERR! peerinvalid Peer @angular/compiler-cli@0.6.0 wants typescript@^2.0.2
    
    npm ERR! Please include the following file with any support request:
    npm ERR!     C:\Users\AxOn\Documents\projects\NODETS+ANGULAR2\public\npm-debug.log
    

    之后,在packege.json中没有sass

    "devDependencies": {
        "concurrently": "^2.2.0",
        "lite-server": "^2.2.2",
        "typescript": "^1.8.10",
        "typings":"^1.3.2"
      }
    

1 个答案:

答案 0 :(得分:6)

将typescript的版本设置为2.0.2有助于修复我的案例中的打字稿错误。

"devDependencies": {
    // other dependecies ...
    "typescript": "^2.0.2",
    // other dependecies ...
  }

可能是这个错误是由于在忘记升级文档的同时升级了角度编译器及其依赖项。