Node-telegram-bot-api: Can anyone explain me about ES6?

Created on 4 Jun 2016  路  9Comments  路  Source: yagop/node-telegram-bot-api

I`m really lost...
Can you explain me the difference between the module I get using "npm i node-telegram-bot-api" and the one I get with "git clone https://github.com/yagop/node-telegram-bot-api"
They are different. The one from NPM is a working nonES6 code, and the one from GIT(HUB) is nonworking ES6.
I really got stuck with it... Feel stupid...

question

Most helpful comment

Can be closed?

All 9 comments

So there is prepublish command in package.json that transforms with babel es6 code to es5 and places taht code to lib directory. It runs before code published to npm.

So you can call that manually npm run prepublish than var TelegramBot = require('./lib/telegram.js');

There is NO prepublish script in NPM distributed module:
"scripts": {
"test": "mocha test/index.js",
"test-cov": "istanbul cover ./node_modules/mocha/bin/_mocha --report lcovonly -- -R spec && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./coverage",
"gen-doc": "jsdoc2md --src src/telegram.js -t README.hbs > README.md",
"jshint": "jshint src test"
},

@zigzag-way You can install directly from github ex:
npm install https://github.com/w-site/node-telegram-bot-api.git

Yes, I know that I can directly install it using npm install https://github.com/w-site/node-telegram-bot-api.git
But, the qn is why the module I get is different in this two cases?

@infernalmaster "and places taht code to lib directory" - there is no LIB directory when I use "npm i node-telegram-bot-api" command.

I dont need any additional actions because I`m using OPENSHIFT and it does everything automatically (get the needed modules from npm).

@zigzag-way So if you install from npm install node-telegram-bot-api this is https://github.com/yagop/node-telegram-bot-api/tree/v0.20.1 this release version, but if you install from github you pick the main repository, ant the problem that you can not use npm install https://github.com/yagop/node-telegram-bot-api.git that is lib directory isn't in repo.

Can be closed?

Before closing this issue, I would like to inquire for some insight in the following query.

package.json has its "main" property pointing to "./lib/telegram.js" (at line 5). If I delete the 'lib' directory and try load the module, it succeeds, despite the Node.js Docs mentioning, in the folders as modules section, that _"Note: If the file specified by the "main" entry of package.json is missing and can not be resolved, Node.js will report the entire module as missing with the default error..."_. Instead, Node.js seems to load the module using index.js.

So, why does the require() succeed?

It seems that Node.js defaults to the index.js if ./lib/telegram.js is not found!

@zigzag-way: your earlier remark on "non-working ES6" is being addressed in PR #252!

Closing this now!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Hostile picture Hostile  路  3Comments

alikhil picture alikhil  路  3Comments

dimawebmaker picture dimawebmaker  路  3Comments

Dohoon-Kim picture Dohoon-Kim  路  3Comments

saeedhei picture saeedhei  路  4Comments