Open mkscala opened 8 years ago
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.
Also seeing this issue. AFAICT the correct version of underscore is installed:
$ npm list underscore
angular2-quickstart@1.0.0 ~/Projects/angularjs/udemy/angular2-course
├─┬ lite-server@2.2.2
│ └─┬ browser-sync@2.16.0
│ └─┬ browser-sync-ui@0.6.1
│ └─┬ weinre@2.0.0-pre-I0Z7U9OV
│ └── underscore@1.7.0
└── underscore@1.8.3
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 ?
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"*/
}
}
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).
Thanks dawudr and imbroglioj - it is working for me now.
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
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! angular2-quickstart@1.0.0 start:
tsc && concurrently "npm run tsc:w" "npm run lite"
npm ERR! Exit status 2