2016-02-19 66 views
1

我運行一個節點的應用程序,這是我在app.js:爲什麼我不能在節點中設置時間區域設置?

var moment = require('moment'); 
moment().locale('fr'); 
console.log(moment.locale()) 

我預計這將輸出「FR」,但它輸出「恩」,而不是當我

runjs app.js 

node_modules/moment/locale中有一個fr文件夾。

這裏是我的包:

{ 
    "name": "zenqa", 
    "version": "1.0.0", 
    "description": "Faq for Zenconomy.se", 
    "main": "index.js", 
    "dependencies": { 
    "body-parser": "^1.14.2", 
    "concat-files": "^0.1.0", 
    "express": "^4.13.3", 
    "marked": "^0.3.5", 
    "moment": "^2.11.2", 
    "mustache-express": "^1.2.2", 
    "node-sass-middleware": "^0.9.7", 
    "php-unserialize": "0.0.1", 
    "requestify": "^0.1.17", 
    "validator": "^4.8.0" 
    }, 
    "devDependencies": {}, 
    "scripts": { 
    "test": "echo \"Error: no test specified\" && exit 1" 
    }, 
    "author": "Kristoffer Nolgren", 
    "license": "ISC", 
    "repository": { 
    "type": "git", 
    "url": "[email protected]:kristoffernolgren/ZenqaMiddleware.git" 
    } 
} 

回答

-1

當前文檔是不正確的。在Node.JS中,您仍然使用此代碼:

moment.lang('fr');

+0

@Himmators它適合你嗎? –

1

根據文檔有一個錯誤,防止加載moment.locale。所以你可以使用下面的代碼。

var moment = require('moment'); 
require('moment/locale/fr'); 
console.log(moment.locale()); 
+0

這爲我做了詭計。謝謝! – mikeym

相關問題