engine-strict

1.0.0 • Public • Published

Introduction

This package allow to treat npm modules as if the user had set engine-strict, it works also on npm version > 3

The package use the semver standard to check the version

// check                 
// exec node version = '1.2.3'
// engines verion specified in package.json: '1.x || >=2.5.0 || 5.0.0 - 7.2.3') 
// it return true

You can use all range types of semver.

Show more on semver

Getting started

You need to specify in your package.json the engines you would use, for example:

...
"engines"{
  "node": "7.10.0",
  "npm": "4.2.0"
}
...

Then require the module in your main project file and run check:

// index.js
'use strict';
 
const engineStrict = require('node-engine-strict')
 
engineStrict.check()
 

To find the correct package.json you need to check that process.cwd() point to your project root dir, because if you use pm2 or another process manager that run your project from different folder you need to set cwd with process.chdir('path-to-project-root') command, as in the following example:

// index.js
'use strict';
 
const engineStrict = require('node-engine-strict')
const config = require('./config/environment')
 
// Set default node environment to development
process.env.NODE_ENV = process.env.NODE_ENV || 'development';
 
var env = process.env.NODE_ENV;
 
if (env === 'development' || env === 'test') {
 
  if (config.rootDir !== process.cwd()) {
    process.chdir(config.rootDir)
  }
 
  engineStrict.check()
 
}
 
// Export the application
exports = module.exports = require('./app');
 

Feel free to open issues, fork project, and collaborate with us!

Contribute

Clone repository locally and install dependencies:

$ git clone https://github.com/daton89-topperblues/node-engine-strict.git
cd node-engine-strict
$ npm i

Fork project and open pull request

Changelog

1.0.0 first version

Contributors

@daton89 Toni D'Angelo

@topperblues Nicola Bonavita

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.0.0
    408
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.0.0
    408

Package Sidebar

Install

npm i engine-strict

Weekly Downloads

294

Version

1.0.0

License

Apache-2.0

Last publish

Collaborators

  • tonillo
  • topperblues