You are not logged in.

#1 2016-11-26 19:21:08

gleiton
Member
Registered: 2016-11-26
Posts: 3

[SOLVED] Node: npm install package but no executable found

I have installed node tried to install express under default settings
So, according to https://wiki.archlinux.org/index.php/Node.js_ , I followed the step:

$ npm config edit

I uncommented prefix and set:
prefix=/home/gleiton/.node_modules
and added ~/.node_modules/bin to the $PATH

But after installing express

$npm install -g express

and opening a new terminal:

[gleiton@gleiton ~]$ express -h
bash: express: comando não encontrado
[gleiton@gleiton ~]$ whereis express
express:
[gleiton@gleiton ~]$ ls .node_modules/
etc  lib
[gleiton@gleiton ~]$ npm list --depth=0
/home/gleiton
└── express@4.14.0

As we can see, there is no bin directory, neither in ~/.node_modules nor in /usr/lib/node_modules.
And, no executable known as "express"

Last edited by gleiton (2016-11-29 13:34:18)

Offline

#2 2016-11-27 12:15:58

robg
Member
Registered: 2015-03-05
Posts: 218

Re: [SOLVED] Node: npm install package but no executable found

Are you sure that setting the prefix took effect? Browsing through the wiki page you linked to, I suggest you try

npm -g install express --prefix /home/gleiton/.node_modules

and report back on whether that was successful.

Offline

#3 2016-11-28 15:58:53

gleiton
Member
Registered: 2016-11-26
Posts: 3

Re: [SOLVED] Node: npm install package but no executable found

@robg thanks for the tip. I chose setting prefix by npm config edit, and I've seen files were copied there.
Anyway I executed your command line, logged in again but nothing.
Files related to express are installed, but no command "express", and no "bin" directory.

$ find ~/.node_modules/ -type f -name express
(nothing shown)

Offline

#4 2016-11-28 20:50:36

robg
Member
Registered: 2015-03-05
Posts: 218

Re: [SOLVED] Node: npm install package but no executable found

I checked it out myself and you are right. However the solution to your problem is not far: If you check ~/.node_modules/lib/node_modules/express and have a look at the content of the Readme.md file in that folder you'll notice that the command line utility for express is apparently in a separate package called "express-generator". In fact executing

npm -g install express-generator --prefix ~/.node_modules

did the trick for me.

Offline

#5 2016-11-29 13:10:49

gleiton
Member
Registered: 2016-11-26
Posts: 3

Re: [SOLVED] Node: npm install package but no executable found

Great! That worked for me too. Now there's something in bin/ path.

$ find ~/.node_modules/ -type f -name express
/home/gleiton/.node_modules/lib/node_modules/express-generator/bin/express
$ find ~/.node_modules/ -type l -name express
/home/gleiton/.node_modules/bin/express

Maybe my book is outdated, but the documentation is clear. Reading the old Readme is always a good idea. hmm
Thanks a lot @robg, I think I can put a "Solved" on this issue, with "perfect" rsrs.

Offline

Board footer

Powered by FluxBB