- App.tsx: full navigation (Auth stack + Main tabs with 5 screens) - Auth: LoginScreen, RegisterScreen, ForgotPasswordScreen - HomeScreen: dashboard with IoT metrics, weather widget, alerts, quick actions, sensors - MapScreen: interactive map with layer toggles (6 layers) - MarketplaceScreen: categories (6), products (5), search - ChatScreen: AI chat with quick prompts (4), bot responses - ProfileScreen: user info, stats, menu (9 items), logout - AlertsScreen: alert list with severity, acknowledge - SensorsScreen: sensor list with type filters (6 types), search - ZonesScreen: zone cards with stats - SettingsScreen: language picker (FR/EN/ES/DE), privacy, about - Stores: iotStore (sensors, zones, alerts), notificationStore, uiStore + i18n - Hooks: useSensors, useAlerts, useNotifications, useLocation - Components: Card, Button, LoadingSpinner, ErrorBoundary, Header - Services: iotService, notificationService (with axios API client) - Utils: formatters (temp, AQI, noise, dates), validators (email, password, IBAN) - Theme: colors.ts with full design system (Blue Ocean palette) - Ditto: fixed MongoDB connection, new JWT secrets, official gateway image
2.6 KiB
2.6 KiB
requireg

Require and resolve global modules in node.js like a boss.
Differences with require()
requireg tries to find modules in global locations which are
not natively supported by the node.js module resolve algorithm.
It support both npm/yarn global packages installation paths.
Supported locations:
- $HOME/node_modules (instead of $HOME/.node_modules)
- $HOME/node_libraries (instead of $HOME/.node_libraries)
- $HOME/node_packages (specific of
requireg) - $PREFIX/lib/node_modules (instead of $PREFIX/lib/node)
- $NODE_MODULES (use the specific modules path environment variable)
Resolution priority
- Resolve via native
require()(unless second parameter is true) - User home directory (
$HOMEor%USERPROFILE%) - Node installation path
- $NODE_MODULES (can have different multiple paths, semicolon separated)
- Common operative system installation paths
Installation
$ npm install requireg --save[-dev]
$ yarn add requireg
API
requireg(path: string, onlyGlobal: boolean = false)
Usage
Load global modules
var requireg = require('requireg')
// require a globally installed package
var npm = requireg('npm')
Load only global modules
var requireg = require('requireg')
// require a globally installed package and skip local packages
var eslint = requireg('eslint', true)
Resolve module path
var modulePath = requireg.resolve('npm')
// returns '/usr/local/lib/node_modules/npm/lib/npm.js'
Globalize it
require('requireg').globalize()
Now it is globally available from any source file
var globalModule = requireg('npm')
Module not found
requireg maintains the same behavior as the native require().
It will throw an Error exception if the module was not found
Considerations
- Require global modules in node.js is considered anti-pattern.
Note that you can experiment unreliability or inconsistency across different environments.
I hope you know exactly what you do with
requireg - Only node packages installed with npm or yarn are supported (which means only standardized NPM paths are supported)
Possible extra features
- Custom environment variable with custom path to resolve global modules.
License
Released under MIT license