Giter Site home page Giter Site logo

help's Introduction

Node.js Help

Welcome to Node.js Help!

Whether you're a beginner or an experienced developer, Node.js Help is here to assist you with all your Node.js questions and concerns.

Install

To install Node.js, check out this wiki to learn how to install Node.js via binary archive on Linux and AIX.

How to Ask a Good Question

1. Be Specific

  • Provide Context: Explain the background or context of your question. This helps others understand your problem or inquiry better.
  • Avoid Ambiguity: Clearly state what you're asking about. Vague questions can lead to misunderstandings or irrelevant responses.

2. Use Clear Language

  • Avoid Jargon: If your question involves technical terms, ensure they are explained or defined.
  • Be Concise: Keep your question brief and to the point. Long-winded questions can be confusing and may lose the reader's interest.

3. State Your Goal

  • Clarify Your Objective: Explain why you're asking the question and what you hope to achieve by getting an answer.
  • Express Your Expectations: Let others know what kind of answer you're looking for.

4. Provide Relevant Details

  • Include Relevant Information: Give details that are pertinent to your question. This could include error messages, steps you've already taken, or relevant background information.
  • Exclude Irrelevant Details: Avoid cluttering your question with unnecessary information that may distract from the main issue.

5. Be Respectful

  • Be Polite: Remember to use polite language and tone, even if you're frustrated or facing challenges.
  • Appreciate Responses: When someone takes the time to answer your question, thank them for their help, even if the answer doesn't fully solve your problem.

6. Check for Duplicates

  • Search Before Asking: Before posting your question, search to see if it has already been asked and answered. Duplicate questions can clutter forums and waste people's time.

7. Format Appropriately

  • Use Proper Formatting: If you're asking your question on a platform that supports formatting (like a forum or Q&A site), use formatting to make your question more readable. Use headers, lists, and code blocks as needed.

8. Proofread Your Question

  • Check for Errors: Proofread your question before posting to ensure clarity and correctness. Typos or grammar mistakes can make your question harder to understand.

9. Be Open to Feedback

  • Accept Criticism: If someone suggests improvements to your question, consider their feedback constructively. It can help you ask better questions in the future.

10. Follow Up

  • Engage with Responses: Once you receive answers, engage with them. Ask for clarification if needed, and provide feedback on whether the answers were helpful.

What to Ask:

1. Clear and Specific Questions:

  • How can I achieve [specific task] in my Node.js application?
  • What is the best way to handle [specific problem] in Node.js?
  • Can someone help me understand how [specific feature] in Node.js works?

2. Troubleshooting Questions:

  • I'm encountering [specific error] when trying to [specific action]. How can I resolve this?
  • What could be causing [specific behavior] in my Node.js code?

3. Conceptual Questions:

  • Can someone explain the difference between [concept A] and [concept B] in Node.js?
  • How does [specific module or feature] in Node.js work under the hood?

What NOT to Ask:

1. General Programming Questions:

  • How do I write a for loop in JavaScript?
  • What is HTML, and how does it work?

2. Personal Debugging:

  • Would someone be able to debug my entire Node.js project for me?
  • Why isn't my code working? (without providing any specific details or code snippets)

3. Unsupported or External Package Issues:

  • I need help with a third-party package (not related to Node.js core). Can someone help?
  • Why doesn't this external package work in my Node.js project?

4. Opinion-Based Questions:

  • What is the best Node.js framework?
  • Which is better, callback functions or Promises?

5. Duplicate Questions:

  • I didn't find an answer to my question, but it's similar to this other question. Can someone help me anyway?
  • Why hasn't anyone answered my question yet? (without considering it might be a duplicate)

6. Requests for Complete Solutions:

  • Can someone write the entire code for my project?
  • I need help with my homework. Can someone do it for me?

7. Unrelated or Off-Topic Questions:

  • What's the weather like in New York today?
  • Can someone help me with my personal relationship issues?

8. Extremely Broad Questions:

  • How do I become a Node.js expert?
  • What can I do with Node.js?

Note

When inserting your code, use 3 backticks, followed by js as shown below:

```js
console.log('happy coding!');
```
console.log('happy coding!');

Participate

You can participate by asking or answering open questions in the issues section.

External Links

help's People

Contributors

atombug avatar ayase-252 avatar aymen94 avatar barinali avatar bmuenzenmeyer avatar danielkhan avatar j-human avatar jungminu avatar knighton910 avatar marukome0743 avatar maxsxu avatar preveen-stack avatar raisinten avatar redyetidev avatar sheplu avatar trott avatar vdeturckheim avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

help's Issues

bad formatting for node.js API on firefox

Hi I couldn't figure out where the node api docs repo is, so hopefully this bug report can be redirected to the right place.

I love the node.js API docs. Stellar job there for years. However, the latest revision is quite unusable under firefox (42.0, running on slackware-current).

Here is a screen shot. Note that several words worth of left hand content are obscured by the menu column:

node_api_firefox

As you might expect, the API docs look fine under Chromium (version 46.0.2490.71), with the content properly not hiding underneath the menu.

node_api_chromium

Since I use firefox, not chromium, and since the website should be legible no matter the browser, it would be great if the API site's styles could be fixed.

I'd be happy to hack away, but again, I can't find the repo to pull and edit.

Regards,
James

httpServer.setTimeout callback is called twice for a single request (not favicon)

hey all.

Considering this code:

// file: index.js
var http = require('http');

// create a server with a basic request-handler
var server = http.createServer(function (req, res) {
    console.log('request'); // happens once

    res.end('end');
});


// set a socket 4 sec timeout 
server.setTimeout(4000, function (socket) {
    console.log('destroyed'); // happens twice
    socket.destroy();
});


// start listening
server.listen(3000, '127.0.0.1', function () {
    console.log('listening...');
});

4 seconds after a single request, the "onTimeout" callback gets called twice.
This is not a favicon.ico issue. The "request" log shows only once but the "destroyed" log shows twice.

$ node index.js
request     # a single request
#4 seconds later...
destroyed   #1
destroyed   #2

NOTE: This happens only when I pass the host argument to the listen function. When i omit the host it works as expected.
i.e.

// start listening
server.listen(3000, function () {
    console.log('listening...');
});
$ node index.js
request     # a single request
#4 seconds later...
destroyed   #1

I'm not sure if this is a bug or an expected behavior from Node's docs.

I'm using node 5.0 on windows 7 ultimate.

Additional info

Actually the first "destroyed" log happen 4 seconds after the first request even if requests keep coming. If the timeout value condition is not met (i.e. keep the requests coming), the first "destroyed" log comes 4 seconds after the first request (no matter what) and the second log comes 4 seconds after the last request.

$ node index.js
# make a request every second
request    <──
request
request
request
destroyed  <── 4 sec after the first request
request
request
# keep 'em coming...
request
request
request
request
request   # stop requesting
#4 seconds after the last request...
destroyed

Additionally, I've added a console.log(socket) in the timeout callback and a diff shows these props are different:

_events: [ [Function: serverSocketCloseListener] ]
vs
_events: [Function: serverSocketCloseListener]

sync: false
vs
sync: true

_bytesDispatched: 102
vs
_bytesDispatched: 0

_idleStart: 1845
vs
_idleStart: 2086

incoming: IncomingMessage {...}
vs
none

_httpMessage: null
vs
none

Sorry if that was too hmm.. verbose.
Thanks a lot!

require can't acces my file

hello,

when i use require(myfile) it's not working but if i do fs.readFileSync(myfile) it work.

any idea?

Raw keyboard capture with process.stdin doesn't work as expected.

I'm having problems capturing Raw keyboard input in a terminal on windows. This is driving me crazy, because I know that I had implemented this with older versions of nodejs (a year + ago)

Using the latest versions of NodeJS (currently using 4.2.2), capturing input seems buggy.. Unless I am missing something?

What I am running:
stdin = process.stdin;
stdin.on('data', function (data) {
    if (data == '\u0003') { process.exit(); }
    process.stdout.write('Captured Key : ' + data + "\n");
});
stdin.setEncoding('utf8');
stdin.setRawMode(true);
stdin.resume();
What I am expecting:

Immediately after running, the program should react to whatever key is pressed, and output:

Captured Key : T
Captured Key : E
Captured Key : S
. . . etc
What I am getting:

After running the program, the first keyboard input, acts as if it is NOT captured in Raw and it is captured and displayed on screen.

Then when I press the ENTER key, the text I just typed gets pushed to the handler function, AND THEN the program will accept further input in raw as expected.

Looks like as if the program requires an ENTER keystroke to initiate a proper raw mode input mode?

image
pic related: I typed TEST (ENTER). Then the program works as expected.

I am developing a custom TUI so this functionality is crucial for me.
Anyone knows what is this all about? I can't find anything. Also I don't want to use any external libraries.

Thanks !!

request block

how can i prevent my server from block if 40 lakh record takes 30 secs all request in queue would block for 30 sec

var http = require("http");
var url = require("url");
var MongoClient = require('mongodb').MongoClient

http.createServer(function(request, response) {

if (url.parse(request.url).pathname == '/search')
{
    var collection = db.collection('documents');
   // suppose it takes 40lakh record in 30 secs all request block until response end
    collection.find({}).toArray(function(err, docs) {

      console.log("Found the following records");
      console.dir(docs);

      response.writeHead(200, {"Content-Type": "text/plain"});
      response.write(JSON.stringify(docs));
      response.end();

    });


}
else
{
  response.writeHead(200, {"Content-Type": "text/plain"});
  response.write(0 + '');
  response.end();
}
}).listen(8888);

Best way to install Node JS on OS X

moved from nodejs/node#3969 (comment)

While the installer available at https://nodejs.org/en/ seems logical to pick, there are numerous blog posts, tutorials, stackoverflow questions, etc. that point to and even highly recommend alternatives.

All of these different recommendations make installing Node JS on OS X a bit confusing.

My question is:
regarding simplicity of installing, updating and uninstalling as well as being safe to use (even for beginners), which of the following is the best way to install Node and why:

  • use the installer from https://nodejs.org/en/
  • homebrew
  • nvm
  • using homebrew to install nvm and than using nvm to install Node (this seems to be the top recommended alternative to the installer)
  • any other way

Some of the reasons why to choose each of the methods:

Use installer
Easiest to install.
Although it seems to be suggested as the best way, since it is on the Node JS homepage, it can be difficult to uninstall, requires adding the path to the node executable to your system $PATH and also affects admin-only system folders.

Homebrew
Easy to uninstall and update, does not require sudo for installing node packages globally.
However it can be a bit buggy at times, needing for workarounds to make it work correctly.

nvm
Easy to uninstall and update, allows multiple versions.
This seems to be quite a good alternative, yet might seem a bit too much if you only need the latest version.

Homebrew to install nvm, nvm to install node
Benefits of easier updating nvm (along with other software used) while getting the flexibility of nvm to work with node, also nvm supposedly installs Node JS in a better way than homebrew directly.
The negative is you install two things simply to install and manage the third.

Any other way
more customisation?
Not sure about the benefits or issues with other alternatives

Linux rhel 6.0 "install" robustness

When you download 64-bit Linux Binaries (.tar.gz), there are no .rpm packages. I saw the curl/yum series of instructions, however we do not have a Red Hat subscription, so were hoping to use yum to install, but not possible w/out n .rpm package.

Did notice that expanding the packages, all components seem to be there. After setting PATH to the installed directories, I tried an npm install of an application and it worked fine.

-Is this "expand-and-set-PATH" installation valid - or is this a problem waiting to happen?
We installed v4.2.3 on RHEL 6.
-Any caveats?

Thanks and regards

Can NodeJS be usef for push messaging?

I don't have used Node JS neither any push messaging platform but have read about both and have some problems which could be solved by mechanism like push messaging.
I'm not sure this is right place to ask such question but found that I can ask question related to Node JS here.
We need to import large data from one application to some other applications frequently (want to do it real time in best scenario) hosted by our own (for now) servers.
Instead of importing data with pull mechanism I think, push mechanism would be better and I came across Node JS and had a thought that whether can be used for push mechanism in such scenarios or not.
In most of the Node JS examples, I saw it used to connect back end service with front end like browser but in my case, I'm thinking to use it to connect both ends in server side only like one service communicating to other in back end (without knowing to front end like browser).

I need to know point of view of people who have experience with such problems and also with Node JS.

Thanks.

weird problem with process.title

hello,

something weird is happening,

on windows10, when i use in cmd and run node myscript , if i set process.title and then console.log it,
it work like a charm, but, if i spawn the process then process.title when changed just show me unreadable character.

could some ne explain me that?

myscript:

var name = __filename.replace(__dirname,'')
console.log(name);

process.title=name

console.log(process.title)

will show "myscript"

but,

spawn:

spawn('node', ['myscript'], {
   detached: true,
   stdio: [ 'ignore', out, err ]
 }).unref();

will show "h�0�6_Q<t��"

any idea?

use npm XLSX module with stream

my use case is supporting import&export for certain search page. As for export:

Currently I am able to retrieve query result, form the data into a workbook object and then use XLSX to writeFile to a xlsx file on server and then send this file back to browse for user to download.(This works, but I donot want to generate a file on server)

As for import: Browser upload the xlsx file through fileupload, and node server receive the file by busboy middleware, but again, how can I just pipe the file data to XLSX directly and then I can parse this data into json, eventually put the uploaded data to mysql?

Thanks very much if you can give me some advice on this.

Send events from nodejs addon to javascript

I'm currently building an app (Electron) and i need to connect it with a c++ library. I have done most of the binding using the NodeJS c++ addons, but i'm missing an important part that is related with receiving the events generated by the c++ library on my Javascript code.

void Event1(int64_t id)
{

  ArrayBufferAllocator allocator;
  Isolate::CreateParams create_params;
  create_params.array_buffer_allocator = &allocator;
  Isolate* isolate = Isolate::New(create_params);
  {

    v8::Locker locker(isolate); 
    Isolate::Scope isolate_scope(isolate);

    HandleScope handle_scope(isolate);
    Local<Context> context = Context::New(isolate);
    Context::Scope context_scope(context);

    v8::Local<v8::Value> argv[1] = {
      Nan::New("OnWillPlayTrack").ToLocalChecked(),  // event name
    };


    Nan::MakeCallback(isolate->GetCurrentContext()->Global(),"emit", 1, argv); 
  }

  isolate->Dispose();
}

The Event1 is being called by the c++ lib, that has nothing to do with V8, and now I want to fire an event to JavaScript, back to Node (EventEmitter?). I think that the biggest problem is that most of the v8 functions now need an Isolate, and most of the examples found throughout the web are pretty old.

The Event1 code crashes at MakeCallBack with:

Thread 24 Crashed:: App
0   libnode.dylib                   0x000000010a81e35b v8::String::NewFromOneByte(v8::Isolate*, unsigned char const*, v8::String::NewStringType, int) + 43
1   libnode.dylib                   0x000000010a4b042f node::OneByteString(v8::Isolate*, char const*, int) + 15
2   libnode.dylib                   0x000000010a4ba1b2 node::MakeCallback(node::Environment*, v8::Local<v8::Object>, char const*, int, v8::Local<v8::Value>*) + 50
3   libnode.dylib                   0x000000010a4ba240 node::MakeCallback(v8::Isolate*, v8::Local<v8::Object>, char const*, int, v8::Local<v8::Value>*) + 96
4   addon.node                      0x0000000110e62e1f Event1(long long) + 291 (v8.h:6721)

Any help will be greatly appreciated!

missing x,y for current cursor position on process.stdout

I'm a very experienced node.js developer, but not very experienced ANSI terminal developer.

How do I determine the current location of the cursor?

I see that I can determine the window size with process.stdout.columns, process.stdout.rows, and there's a nifty resize event. Awesome.

But there isn't a process.stdout.column and process.stdout.row or process.stdeout.x, process.stdeout.y to tell me where I currently am, which kind of stinks.

Is there a technical reason as to why this isn't available? Or is it just not documented? Or does it need some love and a pull request?

Practical Use Case

I've got a websocket checking on some stuff in the background. Every few seconds it updates a status message in known location the upper right corner. The function should check to see where the cursor is, make the update, and put the cursor back where it was.

Trying to run grunt on a remote app with expandrive (SSH)

I need to install grunt on my staging server... I do not work with local files. I use expanDrive to ssh in to the staging server and that allows me to edit files as if they are local. I figured I could still run node.js locally to create file on the docked drive the expanDrive would upload them. Maybe it is a permission issue but i cant get that to work...

npm ERR! Darwin 15.0.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install"
npm ERR! node v5.0.0
npm ERR! npm  v3.3.6
npm ERR! path /Volumes/SFD/magento_carts/videoplus_basic1_younglivinggear_2015_08_dir/videoplus_basic1_younglivinggear_2015_08/node_modules/.staging/abbrev-5d3fad76853172fe50fff9204f01c834
npm ERR! code ENOTEMPTY
npm ERR! errno -66
npm ERR! syscall rmdir

npm ERR! ENOTEMPTY: directory not empty, rmdir '/Volumes/SFD/magento_carts/videoplus_basic1_younglivinggear_2015_08_dir/videoplus_basic1_younglivinggear_2015_08/node_modules/.staging/abbrev-5d3fad76853172fe50fff9204f01c834'
npm ERR! 
npm ERR! If you need help, you may report this error at:
npm ERR!     <https://github.com/npm/npm/issues>

npm ERR! Please include the following file with any support request:
npm ERR!     /Volumes/SFD/magento_carts/videoplus_basic1_younglivinggear_2015_08_dir/videoplus_basic1_younglivinggear_2015_08/npm-debug.log
```

Should I install node.js / grunt on my server? How?

Error require --harmony in command

throw new Error ('AppJS requires Node is run with the --harmony command line flag'); ^
Error: AppJS requires Node is run with the --harmony command line flag
at Object. (/var/www/tutorial/app/node_modules/appjs/lib/index.js:2:9)
at Module._compile (module.js:435:26)
at Object.Module._extensions..js (module.js:442:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:311:12)
at Module.require (module.js:366:17)
at require (module.js:385:17)
at Object. (/var/www/tutorial/app/app.js:3:11)
at Module._compile (module.js:435:26)
at Object.Module._extensions..js (module.js:442:10)

Please help me fix it, so I just start with node js and AppJS for new project alternative for java.

Use node using fetch script

Our company uses software that makes web app. All pages by jquery, html is made. In this case, the page after making a code stored in the database and each time Web service and then fetch the page html, jquery to together and it gives iis.
Is there a way we can make any file without using code fetch from the database instead of the node and frameworks used jquery
Sorry if English is not good
Thank you for answers

Is fs.close() mandatory?

Must I close files after fs.open and fs.write in the end of a script?

What happens if I don't (in different OSes)?

Does Node closes opened files before normal exit? Before exception exit?

Are there different situations when not closing is safe and when it is not?

Proper way to do inheritance in nodejs

Hi, all. I am new to nodejs.
I don't know if this is a right place to ask such simple question.

I should write the code that could run on browser side and server side.
I found out that I can use require('util').inherits to do inheritance thing in nodejs.
But if I want to let same code run on both client and server side,
how can I do for that? Thanks a lot !

Unable to install v0.12.9 with msiexec like before (v0.12.7)

It works fine with previous version (0.12.7) and the new version 0.12.9 released does not seem to work.

Previous install :

REM start /B /WAIT msiexec.exe /i C:\DIR\approot\lib\node-v0.12.7-x64.msi ALLUSERS=1 INSTALLDIR="C:\NDIR\" TARGETDIR="C:\NDIR\" /quiet  /l*v "%MsiExecLogFile%" 

New install :

start /B /WAIT msiexec.exe /i E:\DIR\node-v0.12.9-x64.msi ALLUSERS=1 INSTALLDIR="C:\NDIR\" TARGETDIR="C:\NDIR\" /quiet  /l*v "%MsiExecLogFile%" 



Error : 
=== Verbose logging started: 12/4/2015  15:26:00  Build type: SHIP UNICODE 5.00.9600.00  Calling process: D:\Windows\system32\msiexec.exe ===
MSI (c) (00:7C) [15:26:00:533]: Resetting cached policy values
MSI (c) (00:7C) [15:26:00:533]: Machine policy value 'Debug' is 0
MSI (c) (00:7C) [15:26:00:533]: ******* RunEngine:
           ******* Product: E:\approot\lib\node-v0.12.9-x64.msi
           ******* Action: 
           ******* CommandLine: **********
MSI (c) (00:7C) [15:26:00:533]: Client-side and UI is none or basic: Running entire install on the server.
MSI (c) (00:7C) [15:26:00:533]: Grabbed execution mutex.
MSI (c) (00:7C) [15:26:00:548]: Cloaking enabled.
MSI (c) (00:7C) [15:26:00:548]: Attempting to enable all disabled privileges before calling Install on Server
MSI (c) (00:7C) [15:26:00:548]: Incrementing counter to disable shutdown. Counter after increment: 0
MSI (s) (68:18) [15:26:00:548]: Running installation inside multi-package transaction E:\approot\lib\node-v0.12.9-x64.msi
MSI (s) (68:18) [15:26:00:548]: Grabbed execution mutex.
MSI (s) (68:E8) [15:26:00:548]: Resetting cached policy values
MSI (s) (68:E8) [15:26:00:548]: Machine policy value 'Debug' is 0
MSI (s) (68:E8) [15:26:00:548]: ******* RunEngine:
           ******* Product: E:\DIR\node-v0.12.9-x64.msi
           ******* Action: 
           ******* CommandLine: **********
MSI (s) (68:E8) [15:26:00:548]: Note: 1: 2203 2: E:\DIR\node-v0.12.9-x64.msi 3: -2147287038 
MSI (s) (68:E8) [15:26:00:548]: MainEngineThread is returning 2
MSI (s) (68:18) [15:26:00:548]: User policy value 'DisableRollback' is 0
MSI (s) (68:18) [15:26:00:548]: Machine policy value 'DisableRollback' is 0
MSI (s) (68:18) [15:26:00:548]: Incrementing counter to disable shutdown. Counter after increment: 0
MSI (s) (68:18) [15:26:00:548]: Note: 1: 1402 2: HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Installer\Rollback\Scripts 3: 2 
MSI (s) (68:18) [15:26:00:548]: Note: 1: 1402 2: HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Installer\Rollback\Scripts 3: 2 
MSI (s) (68:18) [15:26:00:548]: Decrementing counter to disable shutdown. If counter >= 0, shutdown will be denied.  Counter after decrement: -1
MSI (c) (00:7C) [15:26:00:564]: Decrementing counter to disable shutdown. If counter >= 0, shutdown will be denied.  Counter after decrement: -1
MSI (c) (00:7C) [15:26:00:564]: MainEngineThread is returning 2
=== Verbose logging stopped: 12/4/2015  15:26:00 ===

documentation: publish a LTS recommendation for package.json engines semver

Hi,

I am deploying Node on a PAAS that installs node runtime according to the engines field in package.json.

I was wondering what would be a good engines semver configuration for node & npm versions to make sure I get all the important updates while still staying on the LTS branch.

I think adding this to the documentation would be good.

For example, I can do something like

"engines" : {
    "node" : "4.x.x"
  },

Would that be right ?

10x

Linked bindings initialization

Hi!

We've used linked bindings to compile single statically linked node binary for deployment, so i've a question about difference in the initialization process for built-in bindings, linked bindings and native extensions as dynamic libraries.

As far as i can see, linked binding initialization works more like built-in native modules init: module can be called using process._linkedBinding() and initialization function receive v8::String as second argument instead of v8::Object instance of Module.

My question is: is it good idea to hack linked binding initialization to make to behave more like require + DLOpen (create instance of Module and pass it to initialization function) or it's reserved for some internal needs? Maybe where is another, less "private" way to have native extensions as compiled-in modules?

writable.write(chunk) return false?

I want to upload (stream) control the writing process. But the writing process always returns false. Large files upload process stops. The output of the code is as follows;

Node app.js
False
False
False
False

What am I doing wrong?

My code;

app.js

var http = require('http');
var fs = require('fs');

http.createServer(function(req, res){
var readable = fs.createReadStream('read.mkv');
var writable = fs.createWriteStream('write.mkv');

readable.on('data', function(chunk){

  var buffer = writable.write(chunk);

  if(!buffer){ // ----> Always false! Why????

    readable.pause();
  }
  console.log(buffer);

});

writable.on('drain', function(){

readable.resume();

});
}).listen(8090);

Un-called Callback in Node.js

Hi node.js folks i need some explanation on callbacks.

I attach callback to some function and on error inside called function render page by invoke render method and send error page as response to browser.

1:) Does Node.js still hold the callback memory which attached to function?
2:) Does it is cause a memory leak.

running node in apachie

Hai,

I am the beginner of nodejs. I created service using express and I am trying to post the data from my application which is running on 8080(tomcat) and my nodejs server is running on port 3000.
Is there a way to combine both of them in tomcat and run in single server?
Thank you,
Babji.

how to set the timezone for node.js app

Hi team,
When I debug a node.js app, I'd like the timestamp of the log to be set to a certain timezone. How can I realize that? Can anyone here shed some light on how to set the timezone for node.js app?

npm best practices for using node 4

I love the ES6 features of Node 4 but I'm concerned that building an npm package using them will annoy users who include it from older Node versions.

How should I handle this?

How to get properly capitalized file path on Windows?

I have a path, let's say C:\temp\something.js and I want to get canonical version of the path on Windows - so if there is C:\Temp\somethinG.js (note the capital letter T and G) stored on disk, I would like to get this value (path). I know that Windows has case-insensitive file system but the file system still knows how user capitalized directory/file names.

How can I get from the former path the later one in Node.js?

I have already gone through FS API (https://nodejs.org/api/fs.html) and I have not found anything useful (namely fs.realpathSync, fs.statSync, fs.accessSync, path.normalize, path.resolve did not return what I need).

Workaround: I have found out that fs.readdir returns correctly capitalized directory/file names but performance hit is too large for any serious usage.

Note: http://stackoverflow.com/questions/4763117/how-can-i-obtain-the-case-sensitive-path-on-windows (similar question to mine)

Thanks!

(Migrated from: nodejs/node#3352)

Reduce code size of node

Hi,

Is there any way to reduce the code size of nodejs. On a cross compile platform it comes to be about 9 MB.

Also is there a way to reduce initial heap allocated by V8

Thanks
David

How i can Starting my NodeJS Application when linux starting

Hi,
I trying strating my app.js when the system starting. I need to have console becasue I use scanner to input datas.
this is the log error :
Tue Dec 8 09:34:43 2015: Starting ServerNode
Tue Dec 8 09:34:43 2015: /etc/init.d/ServerNode: line 22: node: command not found

To stating automatically my application i made a Sh Script (run when i launch)
and i copy this script in : /etc/init.d/
and give executable rights : chmod 755 /etc/init.d/ServerNode.sh
and : update-rc.d ServerNode.sh defaults
Someone have a idea ?
Thanks for your help (Sorry for my poor english)
Christophe

Why HandleWrap is not managed by GC?

I think nodejs can make HandleWrap to be Persist weak object, so v8 can collect the inaccessible object and close the underlying file descriptor automatically, but why it isn't ?

var net = require('net');
var PORT = 8000;
var tcpServer = net.createServer(function(socket) {
console.log('new client');
// after run out of this callback, `socket' becomes inaccessible, so v8 can collect it
});
tcpServer.listen(PORT);

child_process.spawn() with 'ipc': has JSON built-in?

Hi, the doc says:

'ipc' - Create an IPC channel for passing messages/file descriptors between parent and child. A ChildProcess may have at most one IPC stdio file descriptor. Setting this option enables the ChildProcess.send() method. If the child writes JSON messages to this file descriptor, then this will trigger ChildProcess.on('message'). If the child is an Node.js program, then the presence of an IPC channel will enable process.send() and process.on('message').

In my case I call spawn() with stdio: ['pipe', 'pipe', 'pipe', 'pipe']to launch a C+libuv subprocess in which I open the fd 3 to intercommunicate with the Node process and then pass JSON bodies in both directions.

According to the doc above, in Node I can do process.send(JSON_BODY) and process.on('message', function(JSON_BODY), but:

  • Does it mean that process.on('message', function(JSON_BODY) directly provides a JS object? or just a string I need to parse with JSON.parse()? or a Buffer?
  • Node's IPC are stream-based pipes, so being a stream I should be ready to receive "partial" JSON bodies... or does Node some magic and it guarantees me that any string given to process.send() is totally received in the child process and also that the data/string received in process.on('message') contains all the data written by the subprocess?

Cross-Compile NPM?

I've cross-compiled nodejs successfully. However, I want to cross compile some npm modules. Do you know how can I cross compile node modules?

Thank you in advance!

Is it OK to open issues on behalf of people here?

I'm thinking that for issues like this or this, I'd like to:

  • Open an issue in the help repo for the user.
  • @ mention the user in the help repo issue so they get notifications on the issue.
  • Reply in the original issue that the question is now in this repo and that this is where general help questions should go.
  • Probably close the original issue after providing the link to the corresponding help repo issue in the above step.

That will hopefully seed this repo with more questions and eliminate a small amount of clutter over in the main node repo. It's a small sample size, but it seems that people are not (for the most part) taking the suggestion to ask the question over here. I think opening the question for them and then directing them over here is more friendly than just trying to be more forceful in suggesting that they ask over here.

Thoughts?

EDIT: Potential downside is it may be annoying if something is opened here in error. Like, you think someone is asking a question about a bug in their code but they're reporting a bug in Node. I guess the question is whether the upside is bigger than the downside.

Deploy an Node App in Ubuntu with Nginx, but I dont have a domain name.

Hello my name is Walter Cordero, I've deployed node apps before but I have had a domain name, this time I need deploy a Node App - an API REST built with Restify and Sequelize - but I don't need a domain name.

I found tons of tutorials when explain how do that, but none works for me, I'm trying to deploy the App in AWS EC2 Micro, when I work in my local the app works fine and all methods works, but when tried to deploy the app, I do not have response from my server.

Please I really need do that.

--harmony_modules flag doesn't seem to be working

node --harmony_modules app.js

/Users/tsm/Sites/vita.hu/app.js:5
import path from 'path';
^^^^^^

SyntaxError: Unexpected token import
    at exports.runInThisContext (vm.js:53:16)
    at Module._compile (module.js:404:25)
    at Object.Module._extensions..js (module.js:432:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:311:12)
    at Function.Module.runMain (module.js:457:10)
    at startup (node.js:136:18)
    at node.js:972:3

node -v = v5.0.0
os = osx 10.11.1

Looking for the nodejs repo owner/owners

Hi,

I'm currently indexing the most popular GitHub repos and nodejs owns a bunch of them. The reason for the indexing, is to make it possible for GitHub users to search for commits, diffs among other things in the nodejs repos.

You can learn more about the technology here:

http://gitsense.github.io

And I took some screenshots of what the node repo looks like and what searching for commits and diffs looks like, and put them here:

http://imgur.com/a/EjYGD

Due to GitHub's API call limits and the fact that I'll be indexing 50,000+ repos, polling for new commits isn't the best use of my API limits. To keep the indexes as up to date a possible, I would need the repo owner to use webhooks to notify my indexers of new pushes.

No permission or privileges needs to be granted. The repo owner just needs to use a secret SHA that I would provide, which would be used by GitHub to sign the push events.

Sorry if this isn't the right place to ask this question, but I'm hoping this question will lead to the repo owner.

Thanks,
Terrence

require vs ES6 import

Are there any plans to move from CommonJs modules to ES6 modules and import syntax?

multi ajax call , TTFB too slow

Client have a ajax call , just like:
post_data = "keyword=" + keyword.value;
$.ajax({
type:"POST",
url:"TooltipSearch",
data:post_data,
dataType:'json',
success:function(data)
{
console.log(data)
}
});

Server /TooltipSearch like:
app.post('/TooltipSearch', function(req, res){
var Tooltip_param = '{"Keyword": "'+ req.body.keyword +'"}';
var search = require('./build/Release/florida');
var data = JSON.parse(search.v8access(16, Tooltip_param));

if (data.length > 0) {
    console.log(data);
    result = {result:1,content:data};
}
else {
    result = {result:0, error_msg:'no data!'};
}

    res.contentType('json');
    res.json(result);

});

the TooltipSearch get data is Average 1.3 seconds
but, when i try to call multi ajax call at the same time e.g. 5 times ,
ajax isn't async process , about 6.5 seconds after the last ajax call get response.
Can anyone tell me why this? And how to adjust node js to make ajax normal asynchronous processing. thank you very much~

Invalid characters in buffer

I asked this in the following issue: nodejs/node#3982
However, I still have a few follow up questions:
Why are the characters from U+007F up to U+00A0 considered invalid chars? Because they are not displayable? Also, where in the code is the distinction made whether an character is invalid?

Memory Leak Help

hey!

i discovered that one of my files is causing a memory leak. the memory grows over days. i'm checking everyday with htop and it grows every day more and more. i don't understand what is the reason for the memory leak. i hope somebody can help me.

var config = require(__dirname + '/config'),
  async = require('async'),
  meminfo = require('meminfo'),
  os = require('os-utils'),
  ip = require('ip'),
  timeout = null;


(function reportStats() {
  var cpuUsage = null,
    memUsage = null;

  async.waterfall([
    function(asyncDone) {
      os.cpuUsage(function(_cpuUsage) {
        cpuUsage = _cpuUsage;
        asyncDone();
      });
    },
    function(asyncDone) {
      meminfo(asyncDone);
    },
    function(_memUsage, asyncDone) {
      memUsage = _memUsage;

      // this will send a request to AWS via SQS
      config.logger.request({ cpuUsage: cpuUsage, memUsage: memUsage });
      asyncDone();
    }
  ], function(err) {
    if (err) {
      ....
    }

    clearTimeout(timeout);
    timeout = setTimeout(reportStats, 60 * 1000);
  });
}());

Thanks
kirrg

problem during event transmission node 0.12.7 on windows

hi!

here is my problem:

i've got two files,a and b.

in file a , there is a listener that emit event with ,the received data and some manipulation, to file b.

in file b , there is a function that check data and return a true or false state inside an object ,trough an event emits to file a.

so it look like that:

file a

var event = new eventEmiter()

var listener = new listener();

var format = function(){....}
var b = require('b.js')

b(event)
listener.on('data',function(data){

// data here is a json string

event.emit('data',format(data)/it's an object/)

})

events.on('checked',function(data){

// data here is an object

listener.write(format(object)/it's a string/)

})

file b:

module.exports=function (event){

var checkdata = function(data){

return new object();
} 
event.on('data',function(){

event.emit('checked',checkdata(data))
})

}

so long everything is fine;
my problem now is in my format function return me an error when i try parsing object to string
it tell me :

�,{"type":"handshake","data":{"isvalid":true}}
[SyntaxError: Unexpected token �]

and it's right!

but why the hell when i sent an object in evnet it turn like this?

Make a nodejs app logged in at linkedin for example

Hi, i want to log in my nodejs app in "linked in" with my user and password, and then use the cookie to manage my account data directly in my personal nodejs app, but i can't log in, with a rest client in my browser i can log in but from a https request in nodejs i can't, help me please

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.