Trouble loading node_modules in Intellij idea ultimate - node.js

I am able to get up and running with nodejs by following the steps in this tutorial
http://blog.jetbrains.com/webide/2011/11/webstorm-your-node-app/
However, I am not able to load any modules while running through the ide. The debugger just blows up at the line
express = require("express");
Please note that I have all the modules installed locally(node_modules directory under root of project directory) and not globally.
FYI, I am able to run the same from the command prompt, just not through intellij.
Please note, I am using node 0.6.6. I am running on Ubuntu 11.10 x64.
Thanks
-Venu

I have a suggestion how you may proceed.
First let me describe the problem, then the workaround, then the proposal to get this addressed.
Problem
Blow up at require("express")
Reason
By default intellij will suspend upon any exception. See the breakpoint rule.
You got stuck at the exception.
The exception, in this case, is due to the fact that module.js is trying to resolve the "express". It actually forms different paths and filenames (see logic in module.js, starting line 159).
Because not all permutations of paths and filenames formed properly, exception is thrown at fs.statSync() fs.js 414 just because that path/filename does not exists.
Workaround
Turn off break at all exceptions when startup/loading modules. Turn it back on when your server is running.
Proposal
next iteration of node.js library handles package/module resolution more elegantly? Let me see if there's a bug being filed already.

Related

Cannot GET / error

looked for couple of hours, on how to solve that, but no luck.
I am using VS 2017 preview edition, and trying to open ASP.NET core 2.0 web application, that uses Angular template
when i open the site (f5 or ctrl-f5), the web-browser getting opened with the message
Cannot GET /
I don't know what causing that and how to fix that, tried to clean/rebuild/restart VS/change project port number/restart the computer, what else can I do to solve that?
Depending on what error you have in the client application, the server might not start at all. Local errors like undeclared locals are seldom a problem.
Usually, the web server does not start when a dependency of the module marked as bootstrap is missing, like, for example `entryComponents'.
Another thing that can cause the boostrap to fail, is a missing file: in this case you should have a look at templateUrl and styleUrls.
Manually compiling via ng build (or better ng build --prod) will point you to the offending code.

Basic debugging of Electron apps

I'm using Electron to build a native application, based on existing code (developed with Electron v0.26.1). I'd like to use features available on more recent versions of Electron, so I changed the version number in package.json to v0.36.9 (the most recent one so far) and reinstalled its dependencies.
Now, I fully expected the applicaton to break when running npm start, and indeed it does, but I didn't expect the error message to be so uninformative:
Error opening app
The app provided is not a valid Electron app, please read the docs on how to write one:
https://github.com/atom/electron/tree/v0.36.9/docs
Error: Cannot find module '/home/user/electron/myapp/build'
I'd appreciate if it would say why it is no longer a valid Electron app, give any sort of stack trace, or file causing the issue.
Running npm start did create a build directory like before, which contains several files, just like before the upgrade. From the way it's worded, I cannot know if the Cannot find module message is the cause of the error, or the consequence. And if it is the cause, I have no idea of who or what is requiring such module, since before the upgrade this had never happened.
I tried "standard" debugging techniques, like running npm start --debug (the flag exists, but is not useful in this situation), npm rebuild, reading the Electron FAQ, looking for any *.log files (none to be found), and looking for occurrences of require('build') or something similar (no such occurrences). Nothing helped.
How can I get any information at all about why this is failing? Every programming language/build system I know of would at least output the source file where the error occurred, and possibly more information.
In your app's package.json there probably something like:
"scripts": {
"start": "electron /home/user/electron/myapp/build"
}
That's the command that will be executed when you run npm start, so fix the path in there to point to the .js file that contains your app entry point.
Well, after bisecting changes here and there, and following Vadim Macagon's advice to look further into package.json, I found out that the following change was responsible for the complete failure:
Changing "fs-jetpack": "^0.6.4" to "fs-jetpack": "^0.7.1"
Now, unfortunately I still have absolutely no idea about why that happened, or how I could have possibly found it out other than blindingly changing settings here and there.
This is not the answer to my question (I'd still like helpful information about how to debug Electron apps to avoid similar problems in the future), but it does allow me to keep working. That is, if I decide to keep using Electron, which I'm no longer sure it's a good idea.
Edit: There is at least one related issue on Github, but it has been closed and the issue has not been resolved.

Node-webkit works on Mac, crashes and can't load module on Windows

I've created a full node-webkit app that works fine on the Mac OSX version of node-webkit. Everything works, it loads a key external nodeJS module (marked), and the world is good.
However, when I try to run the app on the Windows version of Node-webkit as described in the Wiki, the app crashes immediately (in fact, it crashes immediately when I try all the options: dragging a folder onto nw.exe, dragging an app.nw compressed folder, and running both from the command line).
The only thing that gets me closer is opening nw.exe and then pointing the node-webkit location bar to the index file. Then I get this error:
Uncaught node.js Error
Error: Cannot find module 'marked'
I tried commenting out the code that requires marked:
var marked = require('marked');
That returns the app to crashing immediately. I assumed it was because of context issues between node.js and the node-webkit browser, but those seem to not be at fault since I tried this suggestion to make sure it finds the correct file for the marked module...went right back to immediate crashing.
I'm out of ideas because the crashes don't seem to leave me any way of knowing what the error was.
Could you specific the crashed nw version on Windows platform?
And please provide a sample code, I want to reproduce it because my test code does not crash (I only have one line JS code).
var marked = require('marked');

Node.js compile error on Linux

I'm currently running a heavily modified Synology DSM (x86 bromolow based) on my server (bootstrapped, etc.), and for some services, I would need node.js.
And thus, I've been following the tutorials, more or less. Installed the required packages (python2.7, make, gcc, etcetera), grabbed the source, checked out the latest stable, and tried to compile.
But I ran into a slight issue while trying to run configure. Here's the output log: http://pastebin.com/BPXX4XiY
Then tried with Python2.6 too: http://pastebin.com/Xg4qHspG
Problem is, Error 38 and "Function not implemented" does not give a slightest hint on what might be missing - there is simply no reference to it.
Did anyone else have this problem, and if yes, how did you solve it?
EDIT
Using the solution from here, it still does not work. /dev/shm/ (after manually creating the node, and mounting it) is there, with 0777 access rights, and yet Python still returns the same error.

IntelliJ Idea 12 Unable To Resolve Express Methods

For some odd reason, I can't seem to have code completion with the "express" object in my node.js project. Here is a screen of it.
My OS is Windows 8 and I am using IntelliJ Idea 12.11. Perhaps I need to do some extra setup? Please let me know.
#CrazyCoder got it right, it is indeed a intellij bug, as of now still unpatched, guess we have to wait =( The URL is http://youtrack.jetbrains.com/issue/WEB-6667. In the meantime, I guess I will have to live with it.
if you are on IDEA 13, you will still not get the Express methods until you use the express typescript stub
go to Javascript Libraries > Downloads and switch the combobox at the top to Typescript community stubs then type express
you should see the stub, it's also here:
https://github.com/borisyankov/DefinitelyTyped/blob/master/express/express.d.ts
if you are on Java 1.7 and haven't disabled the SNI Support you will get a handshake alert and the download will fail, go to the directory where your IDEA.exe is located and add the following line to the idea.exe.vmoptions:
-Djsse.enableSNIExtension=false

Resources