funktionswerk / hapi-i18n

Translation module for hapi based on mashpie's i18n module
MIT License
39 stars 22 forks source link

Error: ENOENT: no such file or directory #31

Closed sachinshah114 closed 4 years ago

sachinshah114 commented 4 years ago

Version : "hapi-i18n": "^3.0.0"

code

const modules = async function () {

    await server.register([{
        plugin: require('good'),
        goodModuleOptions,
    }, {
        plugin: require('hapi-swagger'),
        swaggerModuleOptions,
    }, {
        plugin: require('@hapi/inert')
    }, {
        plugin: require('@hapi/vision')
    }, {
        plugin: require("hapi-i18n"),
        localizationModuleOption
    }]);
    logger.info(`Modules have been installed successfully...`)
};

Options:

const localizationModuleOption = {
    options: {
        locales: languages.split(','),
        directory: './locales',
        languageHeaderField: 'lang',
        defaultLocale: defaultLan
    }
}

When I run the server I got the below error.

Error: ENOENT: no such file or directory, scandir '/var/www/html/project/node_modules/hapi-i18n/node_modules/i18n/locales'

It seems that Module tries to read the data from the above path but folder does not exist in that location. As I have checked on node_module and git repo there is another folder called test and inside the test folder, there is a folder named locales.

Can anyone help me to fix this issue?

kaywolter commented 4 years ago

Use process.cwd() or __dirname to refer to relative path.

sachinshah114 commented 4 years ago

@kaywolter Thanks for the quick reply, I tried but not works. directory: __dirname +'/locales',

kaywolter commented 4 years ago

Did you check if the path is correct and if the directory exists? Do you have write access?