nodejs

Building frontend fails with various (function undefined, etc.) errors

Now happening already two times in my career and spending some time with it, I find it worth telling my problem in this topic. After coming into a new company or to a new (existing) project you try to build the source code to start working on new features. A lot of times it happens that you receive error messages which do not happen on the colleagues work stations. Usually long working employees also fail to detect the root cause of this error. It actually comes from a differend node/npm version and errors from the build are very misleading. Since you (as newly come to the project) usually install a newer version of npm/node, the old backwards incompatible versions fail to build the code. So if it ever happens to you that you cannot build a newly downloaded source code, check the node version of the collegues!

Browsersync is an automation tool that can watch files for changes and inject them into a web page without reload.

Usage:

  • Install Node.js
  • Install Browsersync
    npm install -g browser-sync
  • Start Browsersync
    browser-sync start --proxy "myproject.dev" --files "css/*.css"

Browsersync will create a proxy that will wrap your vhost myproject.dev with a proxy URL.

It can also be used with gulp:

var browserSyncWatchFiles = [
'./style.css',
'./js/*.min.js',
'./*.php'
];
var browserSync = require('browser-sync').create();
var browserSyncOptions = {
proxy: "myproject.dev",
notify: false
};
gulp.task('browser-sync', function () {
browserSync.init(browserSyncWatchFiles, browserSyncOptions);
});

Technology:

How to run Apache And Nodejs together?

Today i was facing the problem to run nodejs on a server which is already running apache as webserver. So i had to choose a different port for the node app, but i didn’t want to enter an url like this http://nodeapp.domain.com:port. So how can I achieve this, without entering the port at the end of the domain?
Subscribe to nodejs