Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unrecognized node flag --icu-data-dir #1151

Closed
bleistift-zwei opened this issue Nov 10, 2020 · 2 comments
Closed

Unrecognized node flag --icu-data-dir #1151

bleistift-zwei opened this issue Nov 10, 2020 · 2 comments

Comments

@bleistift-zwei
Copy link

bleistift-zwei commented Nov 10, 2020

By default, node only ships with US locale information, e.g. for calls to the Internationalization API or for the locale option to Date.prototype.toLocaleString()

In case where recompiling node is infeasible (for instance when working on a team where one doesn’t have control over other people’s node version), there exists the node package full-icu. That package stores the missing locales to node_modules.

In order to use the locales, node must be provided with the --icu-data-dir command line option, for instance:

node --icu-data-dir=node_modules/full-icu <script>

However, ts-node does not recognize the flag.

I’m unsure if this is actually a bug or expected behaviour, since ts-node does by design not respect all node flags.

Steps to reproduce the problem

Setup the project

mkdir icu-mwe
cd icu-mwe
npm init --yes # Create npm project with default configuration
npm install typescript ts-node full-icu
npx tsc --init

Write a script script.ts with the following content:

new Date().toLocaleDateString('de'))

To verify that the locales are indeed not loaded, run

npx ts-node script.ts

and note that the output is in ISO format: “2020-11-10”.

Expected Behavior

npx ts-node --icu-data-dir=node_modules/full-icu script.ts

should print “10.11.2020”.

Actual Behavior

$ npx ts-node --icu-data-dir=node_modules/full-icu script.ts
D:\tmp\icu-mwe\node_modules\arg\index.js:90
   throw err;
  ^                                                                                                                 
Error: Unknown or unexpected option: --icu-data-dir
  at arg (D:\tmp\icu-mwe\node_modules\arg\index.js:88:19)
  at main (D:\tmp\icu-mwe\node_modules\ts-node\dist\bin.js:35:18)
  at Object. (D:\tmp\icu-mwe\node_modules\ts-node\dist\bin.js:448:5 )
  at Module._compile (internal/modules/cjs/loader.js:778:30)
  at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
  at Module.load (internal/modules/cjs/loader.js:653:32)
  at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
  at Function.Module._load (internal/modules/cjs/loader.js:585:3)
  at Function.Module.runMain (internal/modules/cjs/loader.js:831:12)
  at startup (internal/bootstrap/node.js:283:19)

Specifications

  • ts-node version: 9.0.0
  • node version: 10.20.1
  • TypeScript version: 4.0.5
  • tsconfig.json is the default one:
{
  "compilerOptions": {
    "target": "es5",
    "module": "commonjs",
    "strict": true,
    "esModuleInterop": true,
    "skipLibCheck": true,
    "forceConsistentCasingInFileNames": true
  }
}
  • Operating system and version: Windows 10 Pro 20H2, Build 19042
  • If Windows, are you using WSL or WSL2?: No
@cspotcode
Copy link
Collaborator

Duplicate of multiple other issues, for example, #1073, #1076

#1073 (comment)

See also:
https://github.com/TypeStrong/ts-node#programmatic

See also: #1074, where we are awaiting a pull request that improves documentation.

Closing for now, because I think this adequately explains why it's working as intended. We can reopen as needed.

@bleistift-zwei
Copy link
Author

Thank you for your time. I overlooked the note in the section you linked to.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants