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

3
  • 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'). Commented Dec 9, 2015 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 Commented Dec 9, 2015 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? Commented Dec 9, 2015 at 22:57

3 Answers 3

0

It should be

var azure = require('azure-storage');
Sign up to request clarification or add additional context in comments.

1 Comment

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.
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.

Comments

0

In new version you can defined like this.

import  * as azure  from 'azure-storage';

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.