How to use npm country codes - javascript

Hin I am new in node.js. I already created my project in cordova cross platform Mobile Application. Now I want to install npm country-codes package "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. In my Project I used backbone.js and require.js
var countryCodes = require('countryCodes')
console.log(countryCodes)

Pay notice that this page module in NPM says the following:
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/. If you need help with a migration, please file an issue on that repository and tag #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 install country-codes
The error that you are experiencing is created by the common.js library which is the Node.js loader library.
This occurs when there is a require('name') call, but the 'name' module has not been loaded yet.

Related

This dependency was not found

When i try to npm run serve it stops at 98% and :
ERROR
Failed to compile with 1 error
This dependency was not found:
* #/components/HelloWorld.vue in ./node_modules/cache-loader/dist/cjs.js??ref--12-0!./node_modules/babel-loader/lib!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader-v16/dist??ref--0-1!./src/views/Home.vue?vue&type=script&lang=js
To install it, you can run: npm install --save #/components/HelloWorld.vue
I looked up for some sources but never helped. Even installing HelloWorld.vue turns an error.
It looks like one of your files is trying to load a local component called HelloWorld.vue and it may not exist in your project structure. You shouldn't try to "install" it, but rather head to the Home.vue file where this error is being triggered from (see Home.vue at th end of the error message?). Then ask yourself, do you actually want to load HelloWorld.vue?
I imagine you're following some sort of "getting started with Vue" guide and you've been instructed to include that file. You'll have to either create that file in the {YOUR_PROJECT}/src/components/ folder, or remove the code that's trying to load it.
Alternatively, this could be a configuration error in which you're trying to use the # alias but it hasn't been setup in webpack properly. Please include more info if this doesn't solve your problem.
Maybe Vue Js cli is not installed on server
// to install vue on ubuntu
npm install -g #vue/cli
// check if it was installed successfully
vue --version
#vue/cli 4.1.2

Cannot find module 'crawler'

After installing node-crawler in Node.js (not in the default directory) via the npm command, I tried to run the code in the "Usage" section but an error occurs when executing var Crawler = require("crawler"); and the VisualStudio Code debug console says Cannot find module 'crawler'.
Does it happen because I installed crawler in a custom location? How can I fix this?
npm install will install a package locally. (--save to have package appear in your dependencies.)
To have access to it from everywhere, you need to install it globally, using npm install -g
Maybe I found the solution. I replaced "crawler" in var Crawler = require("crawler"); with the path that points to the crawler.js file in the lib folder in node-modules, and now the code works. Maybe it happened because I installed crawler in a custom location and so VisualStudio couldn't find "crawler".

What is the step-by-step procedure for installing any npm module with Aurelia CLI?

I wanted to install jquery and found instructions here:
http://aurelia.io/hub.html#/doc/article/aurelia/framework/latest/contact-manager-tutorial/4
I then wanted to install "moment.js" and found instructions here ( I am not using typescript) :
How to import Moment-Timezone with Aurelia/Typescript
To install both of these with the Aurelia CLI the procedure is to install the respective npm module and then to manually modify aurelia.json in some way so the app recognizes it.
In the case of moments the instructions then say to place an import at the top of app.js , but this is not the case for JQuery.
First off , is there any way the changes to aurelia.json can be automated ( like a regular node.js package.json) so I don't need to manually do it and second, how do I know what modifications I am expected to make to aurelia.json ( or app.js or any other file) for the module I want to install?
With a basic node.js app its pretty simple , just npm install. With Aurelia its much more confusing.
Edit: There is also JSPM which I've read is used for front end libraries like the ones I mentioned above. However, the links with instructions for installation that I posted are not using JSPM.
Edit
I found some of the answers here:
http://aurelia.io/hub.html#/doc/article/aurelia/framework/latest/the-aurelia-cli/6
The CLI is still under development. I think the automatic adding of a package might some day be included in the CLI itself, for example with an install command.
The extra registration is required to register the package correctly for usage with RequireJS (http://requirejs.org/). And if the plugin exists of more than just 1 file, this registration is a bit more complex then just adding the name of the plugin.
There is an experimental CLI task here https://github.com/martonsagi/aurelia-cli-pacman that will do the automation for you.
Which can be installed by running:
npm install aurelia-cli-pacman -D
The above will install the package manager and register/ include itself in the tasks in your current project (be sure to run it with install, because npm won't run the post install script if you run it the i shorthand). Next, you can run the following command to install an extension:
npm i aurelia-interactjs -S
au pacman i aurelia-interactjs
The only downside for many might be that currently there aren't that many registry entries, but I think the author of the package would be very happy if you help him out by creating a pull to extend the registry. Would take you some time to figure out what would be the correct install/ import settings, but you will help out someone else and make them happy when they hit the same problem you experience :-).
JSPM has a same sort of issue around this, only is more matured/ the registry is bigger and/ or authors added specific information for JSPM installations to their package.json. For example: To install the above plugin with JSPM it will use the following highlighted section https://github.com/eriklieben/aurelia-interactjs/blob/master/package.json#L72,L86. The same is currently not possible with aurelia-cli, because the installation is done by NPM instead of through JSPM that redirects it to NPM.
If the author of the plugin didn't specify the JSPM section in the package.json, you would most likely and up with the same sort of issues. JSPM has a similar registry (https://github.com/jspm/registry/tree/master/package-overrides/npm) as aurelia-cli-pacman.

react-native-db-models Uncaught error

I am wanting to use the react-native-db-models for local-db on my React Native iOS app.
I've npm installed react-native-db-models from here and have followed the instructions on the page of creating a db.js file that contains the example given on both Github page and NPM page. Then in the file that needs access to the DB, I've created vars for both DB and DBEvents, following the docs accordingly.
When running the project in Xcode it results in a Build Fail.
uncaught error Error: UnableToResolveError: Unable to resolve module
util from /Users/tmhn/Project/DoppioHealth/node_modules/react-native-db-models/node_modules/promise-es6/lib/utils.js:
Invalid directory /Users/node_modules/util
I have also npm installed the two dependencies listed on the npm page: es6-promises and eventemitter3, to no avail.
Note: DoppioHealth is the project name
Investigated the Github Issues and found this solved the issue

Meteor: "ReferenceError: module is not defined" after installing package

I created meteor package which contains ZiggeoSDK api to integrate ziggeo into my meteor app. After installing this package it is giving error:
ReferenceError: module is not defined
Ziggeo is Node Server SDK repository. And package contains ziggeo-sdk.min.js file.
Does anyone know how to resolve this issue.
Your problem is located at the line #11 in https://github.com/Ziggeo/ZiggeoNodeSdk/blob/master/ziggeo-sdk.js
This project uses Node.js modules. Check the require() functions too, they load other npm dependencies such as crypto or http.
You need to ask the owner for the npm package or create one yourself https://docs.npmjs.com/getting-started/creating-node-modules. Once the packages is ready, load it in Meteor using meteorhacks:npm.

Categories