Use natural nodejs library in Meteor project - javascript

I need to use natural (https://github.com/NaturalNode/natural), a nodejs library inside a Meteor project.
If I install natural using npm inside my Meteor project, it throws a bunch of erros becouse certain aspects are incompatible: (Doctype HTML in html file headers, for example, which meteor doesn´t like much.)
Can anyone teach me how to turn natural in an meteor package or just tell me how to solve this problem?
Thanks,

Try this project. I haven't tried it myself, but there are likely some leads there.

Try this package in Atmosphere (a collection of Meteor packages) https://atmospherejs.com/package/natural
To install packages from Atmosphere,
You will need meteorite:
npm install -g meteorite
install the package:
mrt add natural
run your project
mrt
Easy this time ;) Enjoy!

Related

How do you build a local package before it is installed elsewhere?

I am building a local package in one directory (lib), and locally installing it from another directory (app). Both projects are typescript.
I've figured out how to do this, but since I am using typescript, it would be very convenient to compile the library when I run npm install -D ../lib from inside app. Is there a way of doing this? I defined a preinstall script in the library, but it doesn't run unless I run install in lib.
Using that knowledge, I could create a preinstall in app that would go into lib and build it, but that doesn't sit right with me. Is there an alternative? A part of the lifecycle that runs when somebody else is installing the current project?
As far as I know, you can use install script. It'll excecute when installing the package. This works fine for me.

How to make NPM package manager refer to my version of a library?

I want to make a bug fix in an NPM library.
How to make my software using package.json to refer to my version of the library (probably a directory on my disk with the library) rather than to the "standard" version of the library from npmjs.org, so that I would be able to debug my version of the library?
You just need to run npm install like you normally would. The only difference is that instead of doing npm install <package-name>, you're going to do npm install /path/to/local/package
Here's an article explaining in more detail

What is the step-by-step procedure for installing any npm module with Aurelia CLI?

I wanted to install jquery and found instructions here:
http://aurelia.io/hub.html#/doc/article/aurelia/framework/latest/contact-manager-tutorial/4
I then wanted to install "moment.js" and found instructions here ( I am not using typescript) :
How to import Moment-Timezone with Aurelia/Typescript
To install both of these with the Aurelia CLI the procedure is to install the respective npm module and then to manually modify aurelia.json in some way so the app recognizes it.
In the case of moments the instructions then say to place an import at the top of app.js , but this is not the case for JQuery.
First off , is there any way the changes to aurelia.json can be automated ( like a regular node.js package.json) so I don't need to manually do it and second, how do I know what modifications I am expected to make to aurelia.json ( or app.js or any other file) for the module I want to install?
With a basic node.js app its pretty simple , just npm install. With Aurelia its much more confusing.
Edit: There is also JSPM which I've read is used for front end libraries like the ones I mentioned above. However, the links with instructions for installation that I posted are not using JSPM.
Edit
I found some of the answers here:
http://aurelia.io/hub.html#/doc/article/aurelia/framework/latest/the-aurelia-cli/6
The CLI is still under development. I think the automatic adding of a package might some day be included in the CLI itself, for example with an install command.
The extra registration is required to register the package correctly for usage with RequireJS (http://requirejs.org/). And if the plugin exists of more than just 1 file, this registration is a bit more complex then just adding the name of the plugin.
There is an experimental CLI task here https://github.com/martonsagi/aurelia-cli-pacman that will do the automation for you.
Which can be installed by running:
npm install aurelia-cli-pacman -D
The above will install the package manager and register/ include itself in the tasks in your current project (be sure to run it with install, because npm won't run the post install script if you run it the i shorthand). Next, you can run the following command to install an extension:
npm i aurelia-interactjs -S
au pacman i aurelia-interactjs
The only downside for many might be that currently there aren't that many registry entries, but I think the author of the package would be very happy if you help him out by creating a pull to extend the registry. Would take you some time to figure out what would be the correct install/ import settings, but you will help out someone else and make them happy when they hit the same problem you experience :-).
JSPM has a same sort of issue around this, only is more matured/ the registry is bigger and/ or authors added specific information for JSPM installations to their package.json. For example: To install the above plugin with JSPM it will use the following highlighted section https://github.com/eriklieben/aurelia-interactjs/blob/master/package.json#L72,L86. The same is currently not possible with aurelia-cli, because the installation is done by NPM instead of through JSPM that redirects it to NPM.
If the author of the plugin didn't specify the JSPM section in the package.json, you would most likely and up with the same sort of issues. JSPM has a similar registry (https://github.com/jspm/registry/tree/master/package-overrides/npm) as aurelia-cli-pacman.

Why is underscore installed using npm or bower?

I'm very new to underscore, node, npm etc but I think I'm getting the hang of it. However, I just went on to the underscore.js site to get a copy of it and I saw that there is an option to install via npm or bower. Out of curiosity I ran the install in the rood directory of my project but nothing happened. I'll just link to the underscore library in my index.html, so no worries there. However I don't understand why it is even an option to install with npm. Could someone kindly explain this?
This is in the case you want to require underscore for your server-side code. Then you can add it to your package.json just like any another dependency.
There is nothing browser specific about underscore.js. There is an optional to install it via NPM because people use it with Node.js.
Bower, on the other hand, is a tool for managing client side JS dependancies for websites, so (assuming you are using it to manage your websites JS libraries) you can use it with your website.

package.json generation / npm unused packages

I'm introducing unit testing in my project and for this, I need to make myself a package.json file.
First question is, which unit testing suite are you using? I'm looking forward mocha which seem to be pretty much standard for Node.js projects.
Second question is: Is there any magical way of generating a package.json file? (for dependencies and versions)
Third question is: I've been testing a lot of npm packages while developing my project and now I'm stuck with a lot of probably unused packages. Is there any way to tell which one are useless? (I saw npm list installed which is useful though)
I am using Mocha.
npm init
npm ls will list "extraneous" next to ones that are not in your package.json. But, it sounds like you don't have a package.json yet.
Basically, your workflow is very backward. Here is how it is intended to work:
Start a new project with npm init. It has no dependencies.
Oh, I want to start using a package, say express? Add it to package.json under dependencies, then run npm install.
Oh, I want to start using a package for development, say mocha? Add it to package.json under devDependencies, then run npm install.
You seem to have some existing code with manually-installed packages (via npm install <packageName>), which is a mess. I suggest starting over and following the above workflow.
To answer the third question:
npm prune
will remove all installed modules that are no longer mentioned in your package.json.
And you should really have asked 3 separate questions.
I am also using Mocha. It has code coverage, BDD, TDD, runs in browser. It is pretty complete and also heavily maintained by I think one of the most brilliant javascript/node.js programmers named TJ.
It is almost impossible to guess which version(s) to use. Because npm does not know which version breaks which dependencies. You could probably install all dependencies using something like node-detective. Then you can just install them using npm.js from within javascript. Maybe I would like to tackle this in the future.
I would also probably delete all dependencies , next install needed dependencies back using step(2). But also disc-space is not such a big case anymore with the current HDs.
P.S: I think I also agree with Domenic
I am using vows. It's pretty good, but not perfect. I have found unit testing in node to often be challenging because of async callbacks to dbs & such, and have mostly been testing top level functionality.
Here's your magic: Managing Node.js Dependencies with Shrinkwrap.
The only way to know what packages you are using is to know. You can't generate this programmatically. My advice would be to remove packages aggressively, then retest all functionality - if it breaks, you'll know you need to reinstall one of your packages.
Answering your third question, you can use Sweeper to list unused dependencies, and them remove them from your package.json. Just npm install -g sweeper then on your project directory call sweeper on the command line.

Categories