Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 497
Roman Pushkin Avatar asked Nov 12 '16 06:11

Roman Pushkin


People also ask

How do I resolve npm installation issues?

The easiest way to fix the issue is to pass an additional parameter –legacy-peer-deps to npm install. The --legacy-peer-deps tells the npm to ignore the peer dependencies and continue the installation of the package. Try the below command to install the dependencies for your project.

Where does npm install put files?

Local Installation of Packages: Local packages are installed in the directory where you run npm install <package-name> and they are put in the node_modules folder under this directory.

Where are my npm files?

The npm also has a cache folder, which can be found by running npm config get cache ( %AppData%/npm-cache on Windows). The npm modules are first downloaded here and then copied to npm global folder ( %AppData%/Roaming/npm on Windows) or project specific folder ( your-project/node_modules ).


1 Answers

The problem is that the repository contains .npmignore 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.

like image 169
stdob-- Avatar answered Oct 19 '22 16:10

stdob--