Skip to content

Commit

Permalink
fix: fix the error caused by using bundled time-delta in node env
Browse files Browse the repository at this point in the history
  • Loading branch information
aminya committed Apr 18, 2022
1 parent a6f8423 commit 45cbe22
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Formats difference between two dates as a human-readable string in almost any la

### Node.js

In Node.js environment library will load requested locales automatically.
In Node.js environment library will load requested locales automatically from a relative path.

```js
const timeDelta = require('time-delta');
Expand Down Expand Up @@ -76,7 +76,8 @@ timeDelta.addLocale([enLocale, ruLocale]);

// Creating an instance
const instance = timeDelta.create({
locale: 'en', // default
locale: 'en',
autoloadLocales: false
});

const date1 = new Date('2015-04-01T21:00:00');
Expand Down
4 changes: 3 additions & 1 deletion lib/time-delta.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,9 @@ function requireLocale(localeId) {
);

} catch (error) {
throw Error(`Failed to load locale: ${localeId}`);
throw Error(
`Failed to load locale: ${localeId} from ../locales/${localeId}.js. If using a bundled time-delta, set 'autoloadLocales: false' in the config: ${error}`
);

}
}
Expand Down

0 comments on commit 45cbe22

Please sign in to comment.