Share On Twitter Facebook Google+ LinkedIn Pinterest Tumblr Reddit
Question

Does node js work on Linux?

Tags: node.js linux
Date:
Status:Resolved
Question Id:40

I'm interested in web development on the Node.js platform. My host OS is Windows 7. What would be the preferd way to set up a development environment. Run it directly on the host or in a linux based virtual machine? What are the pros and cons between these two methods?

If I go with a VM, can I still run the text editor and web browser in Windows (for performance reasons)?

Answer
Date:
Correct:No

just my two cents maybe even less:

I'll suggest you a third option: to double install windows/ubuntu setup (preferably ubuntu dist which is most gui friendly) and research this option as well this way you would be more familiar with the linux/unix and even iOS which will even make you understand windows better and a better programmer. Sometimes the virtual box is too slow, while linux is very efficient with resources.

If you have the ability to install a virtual machine,you can also give a go to installing a linux distribution and get yourself familiar with this language/system of OS which a lot of the web is structured upon

Answer
Date:
Correct:No

I am also on Windows 7 and use Virtualbox with a Linux ( debian ) guest, i would recommand it because I for myself am faster doing some stuff in the commandline then clicking arround in Windows.

Another nice feature is that if you put your VM on an USB stick you can take it with you and use it everywhere where a Virtualbox Host is installed, so you can take your whole development environment with you.

It's no problem at all to use your favourite text editor or browser in Windows, just install samba and mount your home directory into Windows. Same goes for your browser since the VM is just another machine in your LAN, instead of pointing your browser to localhost point it to the VMs Ip and you are fine.

Obvious con here is if you don't have any experience with Linux yet you should probably stick to windows because it will take you some time to get into it.

Answer
Date:
Correct:No

We have a system via which we just use a config file, which handles all our problems like path differences ("c:\blarg" vs "~user/blarg") and, as a bonus, lets us control differences between debug and production environments.

Node.js is cross platform, so we totally have developers working on all sorts of computers, and it's no problem at all.

This is an example config file I use on a file storage project:

/**
 * All of these are mandatory except for log_level (which defaults to "info", 1) 
 * and log_echo_to_console (which defaults to false)
 */
exports.config = {
    log_level: 0,
    log_file: "/path/to/send.log",
    request_log_file: "/path/to/send_requests.log",
    log_echo_to_console: true,
    port_number: 8088,
    no_notification_emails: true,
    image_url_base: "http://s3.amazonaws.com/",      // MAKE SURE THIS ENDS IN "/"
    tmp_file_folder:"/tmp/",
    s3_info: {
        key: 'xxxxxx',
        secret: 'yyyyy',
        file_bucket: 'sendtransfer/',
    },
    backend_info: {
        db_info: {
            server: "localhost",
            user: "db_user",
            password: "secret",
            database: "SendRemote",
            pooled_connections: 125,
            idle_timeout_millis: 30000
        },
        memcache_info: {
            host: "127.0.0.1",
            port: "31111",
            pooled_connections: 200,
            timeout: 20000
        }
    },

    debug_server: true
};

For Windows machines, just change the paths. It's all good!

Then in code, you can just type:

var local = require('local.config.js');
fs.writeFile(local.config.log_file);
// etc

Embrace multiculturalism!!!

Answer
Date:
Correct:No

You don't spawn processes on Windows, especially the system processes - it’s just as foreign to Windows as using a registry database to store settings on Linux.

“System level” processes on Windows are spawned by the Service Control Manager, and there are tools for idiots with Unix background that let you easily run arbitrary processes as services without too much messing with the API.

So basically if you rely on spawning processes Windows will screw you up. So don’t.

That to say, Node.js has been partially developed by Microsoft (to have it run well on Azure) so it’s fairly good compared to other languages (e.g. it doesn’t try to fake fork() in any way).

Answer
Date:
Correct:Yes

By default, all NodeJS processes are single threaded. That is one of the core designs of NodeJS, like it or not. Instead of using of different threads of execution, it uses an eventing system.

The concept of threads is the same across Windows and Linux, although they are implemented differently due to underlying differences in the OSes.

http://en.m.wikipedia.org/wiki/Thread_%28computing%29

A process is made up of one or more threads, where threads in a process share the same memory space. Processes do not share the same memory space.

All Node processes only use a single thread, by default.

You can spawn additional threads using the web workers thread module. https://www.npmjs.com/package/webworker-threads

You could possibly make OS specific calls to start to processes, but doing so would make your code system dependent.

If you are trying to spawn external processes on threads in NodeJS, then perhaps Node is the wrong choice for your needs.

Your Answer

Review Your Answer