Skip to content
New issue

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

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

Already on GitHub? # to your account

Unable to generate custom metadata with example script "scriptlibphonenumber-metadata" #7

Closed
AndreasZeiser opened this issue Jan 2, 2017 · 9 comments

Comments

@AndreasZeiser
Copy link

Hey Nikolay

I followed the new docs for generating a set of custom metadata but the example script provided in the docs fails to execute with the following error: sh: libphonenumber-generate-metadata: command not found. This is the script I've included into the package.js: "libphonenumber-metadata": "libphonenumber-generate-metadata metadata.min.json --countries DE --extended",.

What works for me though is the following script: "libphonenumber-metadata": "node bin/update-metadata metadata.min.json --countries DE --extended",.

@catamphetamine
Copy link
Owner

The feature I used is called npm bin when npm adds local .bin/ directories to the shell path before it executes scripts.
https://leanpub.com/setting-up-es6/read#leanpub-auto-npm-and-local-installs

Do a ls node_modules/.bin.

Mine is:

_mocha                            istanbul                          npm-run-all
acorn                             jade                              regjsparser
babel                             js-yaml                           repeating
babel-doctor                      jsesc                             rimraf
babel-external-helpers            json5                             semver
babel-node                        libphonenumber-generate-metadata  sha.js
babylon                           libphonenumber-js-update-metadata uglifyjs
detect-indent                     loose-envify                      user-home
errno                             miller-rabin                      webpack
esparse                           mkdirp                            which
esvalidate                        mocha
handlebars                        nopt

So you see libphonenumber-generate-metadata there.
You may also try to reinstall the package.

@AndreasZeiser
Copy link
Author

This is what I see:

> ls node_modules/.bin
_mocha                  babel-doctor            babel-node              mocha                   rimraf
babel                   babel-external-helpers  istanbul                npm-run-all             webpack

I downloaded your project as zip archive and ran yarn install.

@catamphetamine
Copy link
Owner

catamphetamine commented Jan 2, 2017

Oooooh, so you're using yarn.
I guess that's the case: it just doesn't support npm bin feature.
Alternatively use ./node_modules/libphonenumber-js/bin/libphonenumber-generate-metadata then.

They seem to have fixed that:
yarnpkg/yarn#733
Make sure you're running the latest yarn.
I don't use yarn so it's not officially supported by this repo.
If you find a solution you can send a pull request.

@AndreasZeiser
Copy link
Author

Good to know that yarn doesn't work with npm bin. Thank you for the notice!

Btw. I'm using the latest version of yarn.

@catamphetamine
Copy link
Owner

Good to know that yarn doesn't work with npm bin.

I didn't say that.
On the contrary, seems that yarn has been working with npm bin for a long time now.
You can try to file an issue in yarn repo if you want to dig into that.
That would require creating a minimal simplest project on github illustrating the issue (the runnable file not created inside .bin directory)

@catamphetamine
Copy link
Owner

Furthermore, seems that you're currently inside node_modules/libphonenumber-js folder.
The instructions for building custom metadata is for the root project folder.
So cd to the root project folder and try again.

@catamphetamine
Copy link
Owner

I meant that the command should be run from your project root folder, not this project root folder.

@AndreasZeiser
Copy link
Author

Ah, I got it. There is no issue with yarn.

I was doing all the steps in the libphonenumber-js root folder which I've downloaded as a zip archive. I got confused by the section Metadata generation which requires you to fork this project in order to generate metadata.

@catamphetamine
Copy link
Owner

Yeah, that one was a bit misleading. I rephrased that section.

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

No branches or pull requests

2 participants