1.1.2 • Published 9 years ago
mystuff v1.1.2
mystuff - easier local require
This module makes it easier to organize and require your local modules. It also gives you the ability to set global variables that you can use in all of your projects.
Installation
npm install mystuff
When you require mystuff for the first time it creates a folder named own_modules in your users home directory.
In this folder you can store your own modules.
Own Modules
You can create your modules in two ways: as a single JavaScript file or as a directory.
File
- Create a JavaScript file e.g.
example.jsin theown_modulesfolder. - Write your Code in the file and set the
module.exportsproperty. - Now you can require this file in all of your projects.
const mystuff = require('mystuff');
var example = mystuff('example');
//or
var example = mystuff('example.js');Directory
- Create a directory e.g.
anotherExamplein theown_modulesfolder. - Add a JavaScript file called
anotherExample.jsormain.jsin the new directory. They are used as entry-point. - Write your code in the JavaScript file and set the
module.exportsproperty. - Now you can require this module in all of your projects.
const mystuff = require('mystuff');
const anotherExample = mystuff('anotherExample');Tip: The main.js file ist the prefered entry-point.
cd(path)
Change the directory where your own_modules folder is located in.
The change affects the whole node app.