how to use nodejs packages in meteor - node.js

how to use nodejs package in meteor app.
i tried to install module in app directory it is showing error
npm install skimlinksjs
npm WARN package.json node#0.0.0 No description
npm WARN package.json node#0.0.0 No repository field.
npm http GET https://registry.npmjs.org/skimlinksjs
npm http 304 https://registry.npmjs.org/skimlinksjs
npm WARN engine skimlinksjs#0.0.1: wanted: {"node":"~0.6.15"} (current: {"node":"v0.10.24","npm":"1.3.21"})
skimlinksjs#0.0.1 ../../node_modules/skimlinksjs
What is this error and how to use it in the app?

Don't do that, and remove the node_modules directory. Most node modules will not work like that due to Meteor's file wrapping and ordering. They just won't load properly.
To use a node module:
Grab npm package via mrt add npm command.
Add packages.json file with the list of necessary packages, for example:
{
"candle": "0.4.0",
"oauth": "0.9.11"
}
Afterwards, you can require the package with Meteor.require('packagename');.

Related

Warnings when installing npm modules in project directories, but not when installing globally

I have observed this issue when installing both newsapi and RequireJS. The path to my project directory is as follow: Users\username\project
In my project directory, when I run npm install newsapi --save (installation instructions per the newsapi site or npm install requirejs (installation instructions per the RequireJS site, I get the following identical warnings:
npm WARN saveError ENOENT: no such file or directory, open 'C:\Users\username\project\package.json'
npm WARN enoent ENOENT: no such file or directory, open 'C:\Users\username\project\package.json'
npm WARN project No description
npm WARN project No repository field.
npm WARN project No README data
npm WARN project No license field.
It may be worth noting the project\node_modules\newsapi and project\node_modules\requirejs are still created and they seems to be populated as they should.
I noticed that when I install the modules globally (by running npm install -g newsapi --save or npm install -g requirejs) the installation succeeds without displaying any warnings. Why is this the case? What is happening in my project folder that might be causing this issue?
npm install fhqhwhgads will try to update the local project package.json but npm install -g fhqwhgads will install globally and so there's no package.json to update. So that's why you're note getting an warning with global installation.
If you want to create a package.json so that your dependencies can be tracked and replicated by others (or if you want to publish your code as a package), you can use npm init.

npm list does not show installed package

I'm having trouble understanding npm. I have a node.js project with react, but I am not able to find the latter with npm list.
I certainly have it installed, because my project using react works.
I also have it in my package.json file under "dependencies":
"dependencies": {
"react": "^16.4.1"
}
Also, if I search for react on my drive, I find the module for it in my project folder:
user/Dev/project/node_modules/react
However, if I do npm list react, I get nothing:
me ~/D/project> npm list react
project#0.1.0 /Users/me/Dev/project
└── (empty)
Even if I do npm install or even specifically npm install react --save, no change.
Nor is the package listed with npm list or npm list -g (with or without --depth=0), except I get further indications that npm does not 'see' the react module:
UNMET PEER DEPENDENCY react#16.4.1
I'm using npm v5.6.0.
Any ideas?
I fixed this by running npm update command. (If that doesn't work try to delete node_modules and package-lock.json prior to running npm_update)

npm install suddenly fails

I have been able to install node modules locally in a project for quite some time. All of sudden ALL attempts at installation fail, with the same type of error:
Homers-MacBook-Pro:test homer$ npm install bootstrap#3
/Users/homer
└── bootstrap#3.3.7
npm WARN enoent ENOENT: no such file or directory, open '/Users/homer/package.json'
npm WARN homer No description
npm WARN homer No repository field.
npm WARN homer No README data
npm WARN homer No license field.
I'm not using a package.json file, just hoping to install some modules in a local node-modules directory. I don't understand why npm suddenly thinks it needs a package,json in my Home directory.
I'm on MacOS 10.12.4. There have been no upgrades in the system or in Node since the last successful npm install a couple of weeks ago.
This is just a warning, not errorwhich means you can ignore it. And your package has been successfully installed.
npm WARN homer No description // no description in package.json
npm WARN homer No repository field. // no repository setted in package.json
npm WARN homer No README data // no introcude md found
npm WARN homer No license field. // no lisence type setted in package.json
Above warn messages is all about details of package.json which were caused by package.json not found.
package.json is a config file which stores libraries that you installed by npm. So that you don't have to copy/manage these libraries manually and locally.
Next time for a new environment, you can simply reprocude the denpendencies by npm install, and npm will read your package.json and reinstall packages stored in it.
As commented by #peteb (thanks again), while install packages via npm install [packages], npm will try to check whether your newly installed package is listed in package.json . If the file doesn't exist, then this warn message will be shown.

NPM Warnings - "... is also the name of a node core module."

My Node app constantly displays the following warnings when running npm install, or installing new modules. Am I declaring these modules unnecessarily somewhere or is this expected behaviour?
npm WARN package.json fs#0.0.2 fs is also the name of a node core module.
npm WARN package.json fs#0.0.2 No description
npm WARN package.json fs#0.0.2 No repository field.
npm WARN package.json fs#0.0.2 No README data
npm WARN package.json http#0.0.0 http is also the name of a node core module.
npm WARN package.json http#0.0.0 No description
npm WARN package.json http#0.0.0 No repository field.
npm WARN package.json http#0.0.0 No README data
npm WARN package.json querystring#0.2.0 querystring is also the name of a node core module.
These are things that can be done to fix
Uninstall fs & reinstall fs
npm cache clean
Delete node_modules folder and rerun npm install

Node.js npm install validator

I have to install the validator package for node.js
That's what I did
npm install validator
That's the output
npm http GET https://registry.npmjs.org/validator
npm http 304 https://registry.npmjs.org/validator
npm WARN package.json policyfile#0.0.4 'repositories' (plural) Not supported.
npm WARN package.json Please pick one as the 'repository' field
Any idea what to do here?
Ignore those. They are benign warnings and don't pertain to you as a user of the validator module. The author of the validator module could fix them by correcting it's package.json file. Not sure why NPM prints these here as they are mostly a nuisance to npm users and they are really messages for package authors.

Resources