简体   繁体   English

如何使用npm国家代码

[英]How to use npm country codes

Hin I am new in node.js. 欣然我是node.js的新手。 I already created my project in cordova cross platform Mobile Application. 我已经在Cordova跨平台移动应用程序中创建了我的项目。 Now I want to install npm country-codes package " https://www.npmjs.com/package/country-codes ". 现在,我要安装npm国家/地区代码包“ https://www.npmjs.com/package/country-codes ”。 I already install this from command line But I can't get country codes. 我已经从命令行安装了它,但是我无法获得国家代码。 It's display error 显示错误

"Uncaught Error: Module name "countryCodes" has not been loaded yet for context: _. Use require([])

I don't konw how to solve it please help me. 我不知道如何解决它,请帮助我。 I simple use this from npm doc. 我简单地从npm doc使用它。 In my Project I used backbone.js and require.js 在我的项目中,我使用了ribs.js和require.js

var countryCodes = require('countryCodes')
console.log(countryCodes)

Pay notice that this page module in NPM says the following: 请注意,NPM中的此页面模块显示以下内容:

This module is deprecated . 不建议使用此模块。

Please use the country-data package instead of this country-codes module. 请使用国家/地区数据包,而不是此国家/地区代码模块。 It is more well-maintained and the original author of this repository/package has decided to focus on that module instead. 它的维护性更好,此存储库/软件包的原始作者决定将重点放在该模块上。 Here is a link to it: https://github.com/OpenBookPrices/country-data/ . 这是它的链接: https : //github.com/OpenBookPrices/country-data/ If you need help with a migration, please file an issue on that repository and tag @niftylettuce. 如果您需要迁移方面的帮助,请在该存储库中提交问题,并标记@niftylettuce。

The second thing you need to do is to install it with npm command and it should appear under your node_modules folder 您需要做的第二件事是使用npm命令安装它,它应该出现在您的node_modules文件夹下

npm install country-codes

The error that you are experiencing is created by the common.js library which is the Node.js loader library. 您遇到的错误是由作为Node.js加载程序库的common.js库创建的。 This occurs when there is a require('name') call, but the 'name' module has not been loaded yet. 当有一个require('name')调用,但尚未加载'name'模块时,会发生这种情况。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM