I created my project wth yeoman template generator;

yo @microsoft/sharepoint

command(react choosen as JS framework). than installed youtube search api

npm install youtube-api-search 

so far everything seems ok. enter image description here

But when I try to use api in project I encounter with "Cannot find module 'youtube-api-search'." here error messages in command line when I run "gulp serve";

I only added import YTSearch from 'youtube-api-search'; line to default code and I see these exceptions in commandline

enter image description here

here the lines if you cant see the image;

[11:02:03] Error - typescript - src\webparts\helloWorld\components\HelloWorld.tsx(6,22): error TS2307: Cannot find module 'youtube-api-search'.
[11:02:03] Error - 'typescript' sub task errored after 122 ms
 "TypeScript error(s) occurred."

I also checked youtube-api-search package exist under node_modules directory. so this error message makes no sense at all.

why does this error occurs here and more important how can I able to use third party apis(its not specific for youtube-api-search I think) in yeoman generated project

1 Answer 1


You need to install also TypeScript definitions for youtube-api-search to make it work. TypeScript should understand where to find your module. Since no typings provided you see this error.

I didn't find typings for this particular module (may be the name is different, give it a try), so in order to fix it you need to use commonjs style for loading modules.
Change it to: var YTSearch: any = require('youtube-api-search')

  • Im shocked.. I tried your way and it seems ok now I wonder what if I want to push template to use typings I mean, does it works if I simply run "npm i typings". and what about side effects ? I mean what possible causes this brings in ? But first of all, Thank you so much! Commented Jan 20, 2017 at 11:35
  • I would say that by now it's total mess with a way to provide a typescript definitions for the project. In the past there was tsd, then typings and now @types. Yes it will work and normally no side effects. Commented Jan 20, 2017 at 11:42
  • Hi Sergei, can you help me about this post; "sharepoint.stackexchange.com/questions/205743/…" appreciated for your helps Commented Jan 23, 2017 at 0:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.