I have a beginner question concerning nodejs.
I'm working on two different nodejs projects, let's say project A and project B.
And I would like to use the functionalities of project A in B.
How can I do it??
I was thinking about using git submodules. But is there a possibility to use project A as a node_module. that means that the users only have to update it if a new version of it is available?
Thank you
No need to use git submodules - you can use npm to install a module directly from a git remote url, or directly from GitHub.
e.g.:
npm install <git remote url>
npm install githubname/reponame
See the npm install docs for details.
Related
I am studying a TeamCity project which has to do with a .NET application with Angular at the frontend. What it does not make sense to me is I cannot find anywhere npm install. For example:
The thing is in case I add a dependency in package.json which requires update of node_modules folder, everything works fine as far as the artifacts are concerned and Angular finds the files it needs!!
But how node_modules folder on TeamCity is updated?
Sorry, for being a little bit abstract; honestly, I cannot find npm install anywhere.
I would highly recommend looking at the TeamCity Node Plugin available at https://github.com/jonnyzzz/TeamCity.Node. The plugin, which is also available via the TeamCity Plugin repository for an integrated installer, will allow you to use NVM to install a specific version of Node as well as run NPM to install other dependencies, etc.
I hope this helps!
I would like to develop a chatbot and then chose botkit as the tool to use. Following the steps to install it as described here,I first cloned the repository to my local disk D: this worked but the second step command (for Installing dependencies, including Botkit:)
cd botkit-starter-facebook
npm install
doesn't work giving me the error :
I don't understand what that means so it is hard for me to solve it.
I am using windows 7 x64bits pack 1 and node version 6.9.5 and npm version 3.10.10
Git was not in the path system environment variable and I add it but I am still getting the same error.
This is probably because git is not installed or not in the path. npm is trying to pull some dependency from github but unable to clone it as git is not available. Once you have git working, this should work.
I'm evaluating JHipster; it looks great for rapid development!
Maybe a novice question: I see that the generated .gitignore ignores certain things, e.g.
/node/**
/node_modules/**
So, if I check in the generated project to a repository, and then some other developer in my team checks it out in his environment, the project would not work in his environment. Would it?
Was curious to know how to handle this. Thanks.
Since your git repo won't track node packages, others using your git repo will need install node.js, then run npm install to download all the node packages.
It's similar to them having to have java and maven installed on their environment.
Update: A developer will run 'git clone '. The source (not including node or bower) will be on their workstation. Once they've installed node.js, they'll run 'npm install' and the node directories will be created automatically for your project by downloading them from the Internet. That way you don't need to keep all your node libraries in your own git repository ...just their package name and version in the package.json file (similar to maven dependencies in pom.xml).
No one should commit the node_modules or bower_components to git, what you would do is share the project like you share the maven projects.
Write in the read me what needs to be done to get them ready, for example the installation of yo, bower, grunt or gulp and generator-jhipster.
What is very nice about liquibase, each developer can have his own version of the database, and every commit has its own database version.
What we our team does, if a developer adds something to node js package.json then we mention it in the comment: npm install needed and the same applies for bower.
That way you keep all your environments clean, and if you would like to install continuous integration like "Jenkins or Teamcity" then you make sure Jenkins is building rebuilding the whole project.
I'm working on my application. In parallel, I'm working on updating(and adding to) a couple of the npm installed submodules at the same time.
In my package.json dependencies I have:
"zeke-bootstrap": "git://github.com/twilson63/zeke-bootstrap.git",
When I do npm install, it goes and checks out the repository and puts it under node modules just fine. My question is how to I setup this directory so that I can use git, and do commits, and eventually a push to send my changes in my dependent directory back up to github?
Thanks,
Fred
You can checkout your git repo in the node_modules folder under the same folder name as your module and node will automatically use it. However, I don't think its a very good idea. Modules are modules because they are meant to be developed separately.
The problem drove me crazy, there is a package in npm database, but it has some bugs, which are already fixed in github, how could I make use of the fixed version(github version)?
Edit:
You can install directly from the GitHub repository, even just using the GitHub username and the repository name:
npm install LearnBoost/socket.io
You can also add a <commit-ish>, specifying e.g. a commit hash or a version tag, like so:
npm install LearnBoost/socket.io#1.7.x
Without a protocol, this will be interpreted as git://github.com/LearnBoost/socket.io. You can also prefix the repo with gitlab:, gist: or bitbucket:, respectively. For more information, see Using git URLs as dependencies.
You can install directly from a URL, example:
npm install https://github.com/LearnBoost/socket.io/tarball/master
You can find the URL on Github under "Downloads" on any project page. Select the "Download as tar.gz" link.
Or you can install a tarball:
npm install foo.tar.gz
See npm install(1).
Edit:
I should mention that this works equally well in package.json files. Specify the URL instead of the version in your dependencies, like so:
...
"dependencies": {
"foo": "http://example.com/foo.tar.gz",
"bar": "1.2.x",
...
}
Other temporary solution, get the github project and use npm link (http://npmjs.org/doc/link.html) to link the local folder obtained through git to your node_modules folder in your own project. Anyway in the end, you'll have to wait for the project maintainer to do a npm publish.
Either add the module as a git sub-module (using git submodule) to your project or tell the module maintainer to update the version and trigger a npm publish to update the npm repository.
When using the sub-module way, be aware that you cannot update the reference using npm-commands.