Angular2 - Angular-CLI installing lodash - Cannot find module

前端 未结 5 1849
庸人自扰
庸人自扰 2020-12-19 02:19

Mac OSX El capitan | angular-cli: 0.1.0 | node: 5.4.0 | os: darwin x64

I try to install a 3rd party npm module according to the angular-cli wiki: https://github.com/

5条回答
  •  天涯浪人
    2020-12-19 02:30

    FWIW, as of today (1.0.0-beta.26), adding the scripts entry is not necessary anymore.

    Simply add the proper entries to package.json using:

    npm i --save lodash
    npm i --save-dev @types/lodash
    

    Then, in your TypeScript code, use:

    import * as _ from 'lodash';
    

    The code will run just fine.

    In my case, actually adding the scripts entry was causing issues.

提交回复
热议问题