0

I'm using VS 2015 for developing NodeJS console applications.

I have just created a new project from ExpressApp template. I wanted to use 'azure-storage' packages in code.

I installed using the npm wizard VS 2015 offers and I can see the package installed in the Solution explorer under 'npm'. Yet, I cannot require:

import azure = require('azure-storage');

Saying:

cannot find module 'azure-storage'

cannot find external module file by specified path.

You can see this in the attached picture.

Here's what I did following these two posts: post 1 post 2 What can I do else? thanks

Community
  • 1
  • 1
johni
  • 5,342
  • 6
  • 42
  • 70
  • Check the `node_modules` folder and make sure the lib did actually install correctly. If it's there, delete the folder & rerun `npm install` just to be sure. Also, I'm not familiar with the `import` keyword in Node, is that an ES6 feature? In ES5 you would do `var azure = require('azure-storage')`. – James Dec 09 '15 at 16:42
  • It's a typescript syntax for what you meant. I already did what you suggested, it did not solve my problem. The libs are there – johni Dec 09 '15 at 17:22
  • in that case I'd question the lib name, what does your package.json look like? Do you have an npm link to the package you are using? – James Dec 09 '15 at 22:57

3 Answers3

0

It should be

var azure = require('azure-storage');
Andrew Moll
  • 4,903
  • 2
  • 13
  • 15
  • 1
    if you are importing a typescript library, yes. You seem to be trying to add a JavaScript library which needs to be var since it won't be compiled until runtime. – Andrew Moll Dec 09 '15 at 22:03
0

Currently, there is not an official azure sdk for typescript present. And import in typescript just can import typescript modules.

you can try to leverage the TypeScript type definitions to allow require function in typescript. This solution leverages this answer of Importing node-modules with TypeScript on SO. Code sample should like: ///<reference path='node.d.ts'/> var azure = require('azure-storage'); Be the way, this group has transferred azure sdk for node to typescript https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/node-azure which you can try to use directly in typescript. But the version of this sdk is a little out of date.

Community
  • 1
  • 1
Gary Liu
  • 13,758
  • 1
  • 17
  • 32
0

In new version you can defined like this.

import  * as azure  from 'azure-storage';
Vaibhav Bhatia
  • 528
  • 1
  • 4
  • 12