Roman Pushkin Roman Pushkin - 27 days ago 11
Git Question

Missing directories and files on npm install

I'm trying to install this module with

npm i --save https://github.com/yagop/node-telegram-bot-api.git
.

The reason I avoid
npm i --save node-telegram-bot-api
is that I need some recently added methods (like
sendContact
).

When I install, it's added to my
package.json
as expected:

"node-telegram-bot-api": "git+https://github.com/yagop/node-telegram-bot-api.git",


But when I try to run app that is using this module it says:

Error: Cannot find module './src/telegram'


After poking around a little bit it turned out that there is missing
src
and some other directories. Here is
tree
output:

$ tree ./node_modules/node-telegram-bot-api
./node_modules/node-telegram-bot-api
├── CONTRIBUTING.md
├── index.js
├── LICENSE.md
├── node_modules
(second one is skipped)
├── package.json
├── README.hbs
└── README.md


Why? And how can I fix it?

I tried to
npm cache clean
and
rm -rf ./node_modules/node-telegram-bot-api
, reinstalling, nothing helps.

Answer

The problem is that the repository contains .nmpignore file and the following files and directories are ignored during installation:

# lcov
coverage/
*.log
.package.json

# artifacts & source
README.hbs
output.md
output/
src/
test/
examples/
lib-doc/

# dotfiles
.travis.yml
.eslintrc
.eslintignore
.editorconfig
.babelrc
.gitignore
.git

So if you want to use the latest version from the repository, you need to download it and install it manually. Like that:

cd ./node_modules
git clone https://github.com/yagop/node-telegram-bot-api
cd ./node_modules/node-telegram-bot-api
npm install

Upd.: (imho) it is proper in this case to use a private registry for modules. For example sinopia.