
import * as Hapi from 'hapi';
import { IRevApiOptions, RevApi } from './api/revapi';

let version: string = null;

try {
    version = require('./package.json').version;
}
catch (e) {
    version = require('../package.json').version;
}

function RevApiPlugin(server: Hapi.Server, options: IRevApiOptions, next: any) {
    server.expose('version', version);
    server.expose('api', new RevApi(server, options));
    next();
}

(RevApiPlugin as any).attributes = {
    name: 'revApi',
    version: version
};

export default RevApiPlugin;


import * as Hapi from 'hapi';
import { IRevApiOptions, RevApi } from './api/revapi';

let version = require('../package.json').version;

function RevApiPlugin(server: Hapi.Server, options: IRevApiOptions, next: any) {
    server.expose('version', version);
    server.expose('api', new RevApi(server, options));
    next();
}

(RevApiPlugin as any).attributes = {
    name: 'revApi',
    version: version
};

export default RevApiPlugin;

--- 
+++ 
@@ -2,7 +2,14 @@
 import * as Hapi from 'hapi';
 import { IRevApiOptions, RevApi } from './api/revapi';
 
-let version = require('../package.json').version;
+let version: string = null;
+
+try {
+    version = require('./package.json').version;
+}
+catch (e) {
+    version = require('../package.json').version;
+}
 
 function RevApiPlugin(server: Hapi.Server, options: IRevApiOptions, next: any) {
     server.expose('version', version);
Fix issue with loading version from package.json
