【问题标题】:Missing directories and files on npm installnpm install 上缺少目录和文件
【发布时间】:2017-03-26 09:55:11
【问题描述】:

我正在尝试使用npm i --save https://github.com/yagop/node-telegram-bot-api.git 安装this module

我避免使用npm i --save node-telegram-bot-api 的原因是我需要一些最近添加的方法(例如sendContact)。

当我安装时,它会按预期添加到我的package.json

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

但是当我尝试运行使用此模块的应用程序时,它会说:

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

经过一番摸索,发现缺少src 和其他一些目录。这是tree 输出:

$ 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

为什么?我该如何解决?

我尝试了npm cache cleanrm -rf ./node_modules/node-telegram-bot-api,重新安装,没有任何帮助。

【问题讨论】:

  • 两年后我什至不明白我在问什么......

标签: node.js git npm telegram


【解决方案1】:

问题是存储库包含.npmignore file,并且在安装过程中忽略了以下文件和目录:

# 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

因此,如果您想使用存储库中的最新版本,则需要下载并手动安装。像这样:

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

更新。:(恕我直言)在这种情况下,为模块使用私有注册表是合适的。例如sinopia

【讨论】:

  • 谢谢!这说得通。顺便说一句,您为什么认为使用私有注册表是正确的?你能澄清一下吗?谢谢
  • @RomanPushkin 因为在这种情况下,您可以透明地自动化来自 git 存储库的更新包。并且不要等待从npmjs.com升级包的时候。
猜你喜欢
  • 2014-08-30
  • 2020-01-13
  • 2019-02-06
  • 1970-01-01
  • 1970-01-01
  • 2016-05-28
  • 2016-04-16
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多