Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8808875
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T02:43:52+00:00 2026-06-14T02:43:52+00:00

I have a few common files like logger, stopwatch, metrics, etc. Now, I would

  • 0

I have a few common files like logger, stopwatch, metrics, etc. Now, I would like to add all of them in 1 common.coffee and place this files in a common folder under lib.

lib/common/logger.coffee
lib/common/metrics.coffee
lib/common/stopwatch.coffee
lib/common.coffee

Now, when I have to use these files. I just do a

require( 'lib/common' )

and should be able to call the logger class

like logger.info, etc in the lib files.

How to go about doing it ? Below is the common.coffee but it requires me to say “Common.logger” whenever I have to use it. I dont want the Common prefix

nconf = require('nconf')

environment = process.env.NODE_ENV || 'development'

nconf.file 'environment', "config/#{environment}.json"
nconf.file 'default', 'config/default.json'

module.exports = {
  logger: require('lib/common/logger')
  metrics: require('lib/common/metrics') nconf
  stopwatch: require('lib/common/stop_watch')
}

Also, how can I make a module of the common folder so that I can just use npm to install it.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T02:43:53+00:00Added an answer on June 14, 2026 at 2:43 am

    You could use destructuring assignments on your require call.

    {logger, metrics, stopwatch} = require("lib/common")
    

    another way would be to use a build tool like grunt.js and call a concatination task before building the final deployment articfact.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have over 5 million session files in /var/lib/php5 I would like to delete
I have few common views in most of my viewControllers . What I noticed
I have to implement a few action. Each of they have some common elements,
I have few basic questions on session management in GWTP. Now, we create a
I have few text fields like SSN , phone number and email id. I
I have a few different applications that share some common DLLs. At the moment
I have two html files (for add and edit) which contains js codes. These
I have a number of shell scripts that all look like this: #!/bin/bash cd
I have a few tomcat applications, deployed in tomcat using .war files. Even though
I have few sites, and they all have identical setup on a single server.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.