angular2-course icon indicating copy to clipboard operation
angular2-course copied to clipboard

I get the below error

Open mkscala opened this issue 9 years ago • 6 comments

[email protected] start /Users/mkmani/udemy/angular2-course tsc && concurrently "npm run tsc:w" "npm run lite"

app/posts/posts.component.ts(6,20): error TS2307: Cannot find module 'underscore'.

npm ERR! Darwin 15.6.0 npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "start" npm ERR! node v6.5.0 npm ERR! npm v3.10.3 npm ERR! code ELIFECYCLE npm ERR! [email protected] start: tsc && concurrently "npm run tsc:w" "npm run lite" npm ERR! Exit status 2

mkscala avatar Sep 12 '16 23:09 mkscala

The easiest way to fix your problem would be to include <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.3/underscore.js"></script> under index.html.

However, there are better ways to import 3rd party libs. Take a look at angular2-cli on github.

jjhidalgar avatar Sep 15 '16 23:09 jjhidalgar

Also seeing this issue. AFAICT the correct version of underscore is installed:

$ npm list underscore
[email protected] ~/Projects/angularjs/udemy/angular2-course
├─┬ [email protected]
│ └─┬ [email protected]
│   └─┬ [email protected]
│     └─┬ [email protected]
│       └── [email protected] 
└── [email protected] 

I am using npm 3.10.3 / node 6.4.0. The error message says Tell the author that this fails on your system !

Tried to figure this out but no progress. The direct reference to underscore suggested above didn't work either. To get the app 'working' I had to remove the underscore dependency, from posts.component.ts - the app will load but posts obviously don't work.

Mosh - are you planning to update the dependencies to the Angular 2.0.0 release rather than the rc ?

matthewhegarty avatar Sep 20 '16 11:09 matthewhegarty

Its seems that --ambient flag to install dependencies is deprecated. When I ran the below got the error. So I comment the ambientDependencies in typings.json and used --global flag instead and it worked.

typings install dt~underscore --ambient  --save
typings ERR! deprecated The "ambient" flag is deprecated. Please use "global" instead

typings install dt~underscore --global --save

My typings.json now looks like....

{
  "globalDependencies": {
    "core-js": "registry:dt/core-js#0.0.0+20160602141332",
    "jasmine": "registry:dt/jasmine#2.2.0+20160621224255",
    "node": "registry:dt/node#6.0.0+20160807145350",
    "underscore": "registry:dt/underscore#1.8.3+20160908111004"
  },
  "ambientDependencies": {
    /*"underscore": "github:DefinitelyTyped/DefinitelyTyped/underscore/underscore.d.ts#f0990e288ac73d593e982995947567aa2643b828"*/
  }
}

dawudr avatar Sep 21 '16 11:09 dawudr

Thanks to dawudr. Your solution worked perfectly for me. I had to install typings first npm install -g typings For others, note that it is a tilde in "dt~underscore" (not a hyphen).

imbroglioj avatar Sep 27 '16 02:09 imbroglioj

Thanks dawudr and imbroglioj - it is working for me now.

matthewhegarty avatar Sep 27 '16 08:09 matthewhegarty

Thanks dawudr and imbroglioj - it is working for me now. i spent 2 hours solving this issue i posted this on udemy also. But, lastly i somhow came here by searching and found this useful

rrohitesh avatar Feb 01 '17 11:02 rrohitesh