Date toLocaleDateString in node

前端 未结 4 1785
慢半拍i
慢半拍i 2021-01-04 04:49

When I use toLocaleDateString in browser it returns

n = new Date()
n.toLocaleDateString()
\"2/10/2013\"

but in node.js the for

4条回答
  •  青春惊慌失措
    2021-01-04 05:47

    For me, the solution was to install an additional module full-icu for node js full-icu-npm

    And after in package.json insert:

    {"scripts":{"start":"node --icu-data-dir=node_modules/full-icu YOURAPP.js"}}
    

    or

    In the current version of Node.js v10.9.0 is Internationalization Support. To control how ICU is used in Node.js, you can configure options are available during compilation. If the small-icu option is used you need to provide ICU data at runtime:

    • the NODE_ICU_DATA environment variable: 
env NODE_ICU_DATA=/some/directory node
    • the --icu-data-dir CLI parameter:
 node --icu-data-dir=/some/directory


提交回复
热议问题