Im trying to create a angular 4 project with L10n support .I'm trying to use Globalize library in my project .But im getting a lot of error when compling my project.I dont want to use globalize-webpack-plugin or to change my webpack config file .I installed globalize using npm install globalize cldr-data
.But when im trying to use globalize in my .ts file like import Globalize from 'globalize'
im getting error like cant resolve cldr
.
import { Component,OnInit} from '@angular/core'; import * as cldr from 'cldrjs'; import Globalize from 'globalize'; var globalize = new Globalize( "en" ); console.log(globalize);
ERROR in ./~/globalize/dist/globalize.js
Module not found: Error: Can't resolve 'cldr'
Im stuck at this point .Any help is appreciated
You need to add paths to the globalize
and cldr
modules in your tsconfig.json
file like this:
{
...
"compilerOptions": {
...
"paths": {
"globalize": [
"node_modules/globalize/dist/globalize"
],
"globalize/*": [
"node_modules/globalize/dist/globalize/*"
],
"cldr": [
"node_modules/cldrjs/dist/cldr"
],
"cldr/*": [
"node_modules/cldrjs/dist/cldr/*"
],
"jszip": [
"node_modules/jszip/dist/jszip.min.js"
]
}
}
}
将以下内容添加到您的 Webpackconfig 文件中:
resolve: {alias: {'cldr$': 'cldrjs', 'cldr': 'cldrjs/dist/cldr'}}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.