node.js - 如何使用nodemon运行full-icu?

标签 node.js gulp nodemon

当我尝试使用 nodemon 运行 full-icu 时,它没有按预期添加本地化支持。

我尝试通过环境变量包含 full-icu,我使用 dotenv 加载该变量,然后通过 CLI,但还没有成功。我正在运行 Node.js 12.3.1、nodemon 1.19.1、full-icu 1.3.0。

命令行界面:

const gulp = require('gulp');
const {spawn} = require('child_process');

gulp.task('nodemon', () =>
{
    const {stdout, stderr} = spawn('nodemon.cmd', ['--icu-data-dir=/node_modules/full-icu']);
    //...
});

.env:

NODE_ICU_DATA=/node_modules/full-icu

此外,我尝试删除第一个斜杠或包含绝对路径,但没有成功。

当我运行时:

console.log(Intl.NumberFormat.supportedLocalesOf('sk');

输出应为 ['sk'],但对于英语以外的任何语言,实际上都是 []

最佳答案

我通过将 package.json 中的 "scripts" 中的 "start" 更改为:

"scripts": {
    "start": "node ./app"
}

至:

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

CLI 的问题可能是变量顺序错误,因为 --icu-data-dir 前面是 ./app。我猜环境变量的问题是我在进程初始化之后添加了它,而 Node 之后没有检查它。如果情况并非如此,我希望得到纠正。

关于node.js - 如何使用nodemon运行full-icu?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56734597/

相关文章:

node.js - 让 ngPrime 为 Angular 2 工作

javascript - 无法获取/使用 gulp-connect-php

angularjs - gulp 错误 : spawn EACCES

node.js - 为什么我不能在 OSX 10.8.4 上安装 nodemon 或 supervisor?

sql-server - 未使用 TypeScript 和 mssql NodeJS 包执行准备好的语句

node.js - MongoDB 驱动程序 : MongoError: Cursor Not found, 游标 ID : 7820213409290816 in namespace: db_name. collection_name

css - 编译 SCSS 文件

node.js - 当挂载卷中的文件在主机上更改时,文件系统事件不会在 docker 容器中触发

node.js - 在 npm 中找不到 nodemon

javascript - _.clone 在 lodash 中不起作用?