Including other libraries / files / plugins with nodes and NPM

I use OSX 10.5 and play with Nodejs. I managed to install npm and use it to install several plugins. Well, at least the installation says that it works fine, but when I try to download them, I get an error

$npm install htmlparser

Sets ok, then create a file called test with

var htmlparser = require("node-htmlparser");

and run $ node test.js I get

var htmlparser = require("node-htmlparser");
node.js:275
        throw new Error("Cannot find module '" + request + "'");

I have this in the .bash_profile file export NODE_PATH = "/ usr / local / lib / node"

If I cloned the GIT repositories on this page http://github.com/tautologistics/node-htmlparser and moved the file lib / node -htmlparser.js to

~/.node_libraries

then it works great.

What is the point of using npm to install something if I need to move the lib file like this? Am I missing something?

+3
2

var htmlparser = require('htmlparser') , 'node' .

0

, NPM.

npm install htmlparser

  var htmlparser = require("htmlparser");

, npm / node, , , .

0

Source: https://habr.com/ru/post/1765782/


All Articles