Skip to content

npm module installation doesn't install any module #244

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ch-hristov opened this issue Jul 2, 2015 · 6 comments
Closed

npm module installation doesn't install any module #244

ch-hristov opened this issue Jul 2, 2015 · 6 comments

Comments

@ch-hristov
Copy link

Not sure if it's completely the same error but I'm experiencing something similar to #132 :

For a few days I have been trying to get this to work and it's quite possible I'm mising something important.

Here's what's going on :

I'm trying to get the node.js for visual studio extension to recognize my npm modules. Here's what I currenly have :

import http = require('http');
import brain = require('brain');

var port = process.env.port || 1337


http.createServer(function (req, res) {
    res.writeHead(200, { 'Content-Type': 'text/plain' });
    res.end(train());
}).listen(port);

var train = function () {
   var net = new brain.NeuralNetwork();

   net.train([{ input: [0, 0], output: [0] },
       { input: [0, 1], output: [1] },
       { input: [1, 0], output: [1] },
       { input: [1, 1], output: [0] }]);

       var output = net.run([1, 0]);  // [0.987]
       return output;
 }

I have the brain library installed using the built-in npm modules installer inside Visual Studio 2013. The npm module installer comes from the Node.js tools for Visual studio. Whenever I go over the require('brain') it says that it cannot find external module 'brain'.

The problem is whenever I run the application I get the following error :

module.js:338
    throw err;
          ^
Error: Cannot find module 'brain'
    at Function.Module._resolveFilename (module.js:336:15)
    at Function.Module._load (module.js:278:25)
    at Module.require (module.js:365:17)
    at require (module.js:384:17)
    at Object.<anonymous> (C:\Users\Nikolay\Documents\Visual Studio 2013\Projec
s\NodejsWebApp1\NodejsWebApp1\server.js:2:13)
    at Module._compile (module.js:460:26)
    at Object.Module._extensions..js (module.js:478:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Function.Module.runMain (module.js:501:10)
Press any key to continue...

Running the .npm install brain command inside the Node.js Immediate window installs the package but the package is marked as non listed in packages.json and is still unusable.

Sorry if I'm missing something and my question is not reasonable.

Have a great day!

@ch-hristov ch-hristov changed the title npm module installation doesn't install the module npm module installation doesn't install any module Jul 2, 2015
@mousetraps
Copy link
Contributor

There are several issues at play here...

  • The package not being listed in package.json is because you installed it locally, but didn't include the --save command when you were executing npm in the interactive window (which will add it as a dependency of your project.) This shouldn't affect whether your app runs locally, though.
  • The error you are getting when you hover over is coming from the typescript editor, and the only way to get rid of it is by adding a corresponding d.ts file for the module (see our docs). In some cases, like this one, the dts file won't be available, so you would have to create your own (or live with the squiggly)
  • The error you are getting at runtime is the same error you'd get if you didn't have the module installed at all, and I have no idea what would be causing it. @billti, @paulvanbrenk, @ahmad-farid, @NoelAbrahams - any ideas from the TS-end of things?

@mousetraps
Copy link
Contributor

Also mind trying a simple experiment? Create an app.js file with the following contents, set it as the startup file, and start debugging. Do you get a similar error?

var brain = require('brain');
console.log(brain)

If you do get an error... can you check wheter it works when you run node app.js in the command line?

@ch-hristov
Copy link
Author

Update :

Noticing something odd :

  1. I can't seem to reproduce this issue anymore. Could be something with me uninstalling and installing the visual studio tools?

2.Tried the module installation at home, same steps - I get full Intellisense,no intellisense on the machine I'm currently on. Perhaps could be linked to me using Windows7 on the machine that I get the error?

@billti
Copy link
Member

billti commented Aug 21, 2015

I'm not clear from the above - so is this completely gone with a reinstall? Or are you still seeing it on one machine? (Or is that a different issue?)

@billti billti added this to the Future milestone Aug 21, 2015
@ch-hristov
Copy link
Author

After reinstalling the issue was gone.

@billti
Copy link
Member

billti commented Aug 27, 2015

Doesn't seem like much more action to take at this point then. Maybe a corrupt install? Let us know if it happens again and we'll reopen and investigate. Thanks!

@billti billti closed this as completed Aug 27, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants