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.
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.
Related
I have a Laravel application that is hosted on Heroku and serves multiple Javascript games from a single domain. Everything is contained in a single Git repo. The back-end application provides OAuth and other features that are shared by all of the games. Each game is a standalone React app with its own separate node_modules folder. The folder structure looks like this:
├── package.json
├── node_modules
└── games/
└── checkers/
├── package.json
└── node_modules
└── chess/
├── package.json
└── node_modules
└── mahjongg/
├── package.json
└── node_modules
└── public/
├── app-compiled.json
└── games/
└── checkers/
└── app-compiled.js
└── chess/
└── app-compiled.js
└── mahjongg/
└── app-compiled.js
Each time I push a new version of this up to Heroku, I need to run a separate build command to compile the main web application and each of the separate React games. Basically, this is what needs to happen:
npm install
npm run production
cd games/checkers
npm install
npm run production
cd ../chess
npm install
npm run production
cd ../mahjongg
npm install
npm run production
Those commands will compile the React games and place each one under public/games/{slug}/app-compiled.js where they can be served by the common web application.
I already tried adjusting the heroku-postbuild script in my main package.json file to look like this:
"heroku-postbuild": "npm run production && cd games/checkers && npm install && npm run production && cd ../chess && npm install && npm run production && cd ../mahjongg && npm install && npm run production"
That actually works, but I'm worried that it might break at some point in the future as the build process gets bigger and more complex. Is there a better, more supported way to accomplish what I'm trying to do here?
Note that I am not open to the idea of running a separate Heroku dyno for each React app. I am eventually going to have about 30 games, and it would be cost-prohibitive to run each on a separate dyno.
I have a node project my-app that depends on my-other-lib and my-test-lib, my-other-lib also has a dependency on my-test-lib.
This structure in node_modules looks like this:
my-app
├── my-other-lib#1.0.0
└── my-test-lib#1.0.0 (dev dependency)
└── my-other-lib#1.0.0
my-app uses my-other-lib to do some stuff on the production app, my-test-lib is a framework of sorts to help with testing. my-test-lib also makes use of my-other-lib.
I'm writing a test in my-app I want to add a bit of functionality to my-other-lib to help me in that test. I don't need to change any code in my-test-lib to get this working, however I can't figure out how to get this dependency to update without bumping the dependency version in my-test-lib and releasing a new version of it. It feels like I shouldn't have to do that.
If I release my-other-lib#1.1.0, then in my-app run npm install my-other-lib#1.1.0, I end up with this node_modules structure:
my-app
├── my-other-lib#1.1.0
└── my-test-lib#1.0.0 (dev dependency)
└── my-other-lib#1.0.0
One thing that seems odd to me is that my-test-lib specifies the dependency as my-other-lib: "^1.0.0" which implies that it should be fine with using 1.1.0, but still both packages are installed in node_modules.
Is there a way to have my-test-lib use my-other-lib#1.1.0 besides bumping the version in my-test-lib and releasing my-test-lib#1.1.0? And if not, what is the point of specifying the ^ in versions listed in package.json?
my-test-lib is also a npm repository, same as my-app, so you actual structure is the following.
my-app
├── my-other-lib#1.1.0
└── my-test-lib#1.0.0 (dev dependency)
└── my-other-lib#1.0.0
my-test-lib
└── my-other-lib#1.0.0
You need to have control over my-test-lib if you want to upgrade the packages.
let's say your folder structure looks like that:
workspace
├── my-app
└── my-test-lib
The process you should follow is the following (starting from workspace):
// go to your lib
cd my-test-lib
// upgrade my-other-lib
npm upgrade my-other-lib#^1.0.0
//increase your package.json version
// publish your new version
npm publish
// go back to your app
cd ../my-app
// upgrade my-test-lib
npm upgrade my-test-lib#^1.0.0
with this you should end up with the following structure:
my-app
├── my-other-lib#1.0.0
└── my-test-lib#x.x.x (dev dependency) (the new version you published)
└── my-other-lib#1.1.0
Cheers.
Edit: Adding ~/npm/bin to path with PATH=$PATH:~/npm/bin helped, thank you Joachim Isaksson
EDIT:
Seems like i cannot install any packages with npm. After sucessfully installing them, i cannot use them with the assigned commands in the package. "No command '' found".
node -v
v0.11.14
npm -v
2.0.0
At ubuntu machine
It seems like i cannot install the resume-cli module, found here with using npm. Even though it installs without errors, it does not understand the basic commands after installing. Could it be a problem with the warning, showed under?
sudo npm install -g resume-cli
i get
npm WARN engine html-to-text#0.0.8: wanted: {"node":"~0.8.0"} (current: {"node":"0.10.32","npm":"1.4.28"})
Then
/home/bjornasm/npm/bin/resume -> /home/bjornasm/npm/lib/node_modules/resume-cli/index.js
resume-cli#0.3.10 /home/bjornasm/npm/lib/node_modules/resume-cli
├── cli-spinner#0.1.5
├── char-spinner#1.0.1
├── commander#2.3.0
├── colors#0.6.2
├── open#0.0.5
├── chalk#0.4.0 (has-color#0.1.7, ansi-styles#1.0.0, strip-ansi#0.1.1)
├── async#0.9.0
├── read#1.0.5 (mute-stream#0.0.4)
├── terminal-menu#0.3.2 (inherits#2.0.1, charm#0.1.2, resumer#0.0.0)
├── superagent#0.18.2 (extend#1.2.1, qs#0.6.6, methods#1.0.1, cookiejar#2.0.1, component-emitter#1.1.2, reduce-component#1.0.1, mime#1.2.11, debug#1.0.4, readable-stream#1.0.27-1, form-data#0.1.3, formidable#1.0.14)
├── resume-to-text#0.0.15 (mustache#0.8.2, html-to-text#0.0.8)
├── resume-to-html#0.0.21 (gravatar#1.0.6, resume-to-markdown#0.0.14, marked#0.3.2, mustache#0.8.2, lodash#2.4.1)
├── jsonlint#1.6.2 (nomnom#1.8.0, JSV#4.0.2)
└── resume-schema#0.0.15 (z-schema#2.4.10)
Then when running the following
resume --help
i get
resume: command not found
Anyone familiar with this?
Below are the steps to install a given release from source
NOTE - this installs nodejs which gives you both node as well as npm, they come together per release.
to start fresh remove prior node.js and npm installs as well as these :
sudo mv ~/.npmrc ~/.npmrc_ignore
sudo mv ~/.npm ~/.npm_ignore
sudo mv ~/tmp ~/tmp_ignore
sudo mv ~/.npm-init.js ~/.npm-init.js_ignore
to install nodejs and npm as yourself NOT root do these commands (OSX/linux) :
export NODE_PARENT=${HOME}/bin_0_10_32
mkdir ${NODE_PARENT}
download source from : http://nodejs.org/download/
cd node-v0.xxxx
./configure --prefix=${NODE_PARENT}/nodejs
make -j8
make install # IMPORTANT this is NOT using sudo
# not wanted since installing into $USER owned $NODE_PARENT
which puts it into dir defined by above --prefix
export PATH=${NODE_PARENT}/nodejs/bin:$PATH
define environment variable NODE_PATH so node can find dir for modules otherwise
npm install xxx will put newly installed module into current dir :
export NODE_PATH=${NODE_PARENT}/nodejs/lib/node_modules
when you use syntax : npm install -g some_cool_module
the -g for global installs it into dir $NODE_PATH and not your $PWD
nodejs install gives you npm as well :
ls -la ${NODE_PARENT}/nodejs/bin
Subsequent modules you install using global flag -g will automagically put their ~binaries~ into above bin dir ... like browserify
Now put above three export xxx=yyy
commands into your ~/.bashrc or some such so your environment is setup
I tried to install gulp by
npm install -g gulp
The output seems to be something like this. (i have skipped some logs)
npm http 304 https://registry.npmjs.org/string_decoder
npm http 304 https://registry.npmjs.org/lodash._htmlescapes
/usr/bin/gulp -> /usr/lib/node_modules/gulp/bin/gulp.js
gulp#3.6.2 /usr/lib/node_modules/gulp
├── tildify#0.2.0
├── pretty-hrtime#0.2.1
├── deprecated#0.0.1
├── archy#0.0.2
├── semver#2.2.1
├── chalk#0.4.0 (has-color#0.1.7, ansi-styles#1.0.0, strip-ansi#0.1.1)
├── orchestrator#0.3.3 (sequencify#0.0.7)
├── liftoff#0.9.8 (extend#1.2.1, minimist#0.0.8, resolve#0.6.3, findup-sync#0.1.3)
├── vinyl-fs#0.1.4 (graceful-fs#2.0.3, map-stream#0.1.0, mkdirp#0.3.5, vinyl#0.2.3, glob-stream#3.1.9, glob-watcher#0.0.6)
└── gulp-util#2.2.14 (lodash._reinterpolate#2.4.1, dateformat#1.0.7-1.2.3, minimist#0.0.8, vinyl#0.2.3, multipipe#0.0.2, through2#0.4.1, lodash.template#2.4.1)
In the above script i can see a line
/usr/bin/gulp -> /usr/lib/node_modules/gulp/bin/gulp.js
which i guess is making a simulink in bin folder. So i should be getting gulp globally but i get the this error.
No local gulp install found in /var/www/ksapp
Any idea why i am getting this error.
Thanks
As pointed out in the doc, you should install it globally (you did that) and add it to your project dev deps (locally):
npm install gulp --save-dev
I faced the same issue. Got it resolved by creating a link
npm link gulp
Check /home/username/.npm directory: maybe groups/owner of files is root. Change to username:
chown -R username.username /home/username/.npm
I've recently run into the "Local gulp not found" error message. I was able to work past it by creating a symlink from the global node_modules directory to the local project directory where my gulpfile.js is located.
I'm not sure if this is purposeful but when running the...
npm install learnyounode -g
..command in terminal, the module is being created in my home directory. When I try to run the 'learnyounode' command from the directory that I run the npm install from I get the message 'command not found'. I've looked in the usr directory but the learnyounode directory is not in there.
After everything intalls I get the following output
/Users/username/npm/bin/learnyounode -> /Users/username/npm/lib/node_modules/learnyounode/learnyounode.js
learnyounode#0.4.1 /Users/username/npm/lib/node_modules/learnyounode
├── duplexer#0.1.1
├── through#2.3.4
├── boganipsum#0.1.0
├── hyperquest#0.1.8 (through#2.2.7)
├── concat-stream#1.2.1 (bops#0.0.6)
├── bl#0.6.0 (readable-stream#1.0.26)
├── through2-map#1.2.1 (through2#0.2.3, terminus#1.0.9)
└── workshopper#0.7.2 (map-async#0.1.1, tuple-stream#0.0.2, split#0.2.10, mkdirp#0.3.5, xtend#2.1.2, colors-tmpl#0.1.0, terminal-menu#0.2.0, optimist#0.6.1, msee#0.1.1)
ps. I have a fresh install of node in my usr folder. I am more concerned that this problem is going to happen when I want to install other packages via NPM in the future.
I installed without the -g flag and it installed globally.
Trying to install learnyounode,
This path returns:
/Library/Frameworks/Python.framework/Versions/2.7/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin