Fabian L
Fabian L

Reputation: 71

npm global install links to wrong directory

I am using an installation of nodejs, as described here.

When I run this: # npm install -g markdown-pdf

I receive the following error:

(PhantomJS is a Requirement for markdown-pdf):
Phantom installation failed { Error: EACCES: permission denied, link 
'/tmp/phantomjs/phantomjs-2.1.1-linux-x86_64.tar.bz2-extract-
1507729380912/phantomjs-2.1.1-linux-x86_64' -> 
'/usr/lib/node_modules/markdown-pdf/node_modules/phantomjs-
prebuilt/lib/phantom'
errno: -13,
code: 'EACCES',
syscall: 'link',
path: '/tmp/phantomjs/phantomjs-2.1.1-linux-x86_64.tar.bz2-extract-
1507729380912/phantomjs-2.1.1-linux-x86_64',
dest: '/usr/lib/node_modules/markdown-pdf/node_modules/phantomjs-
prebuilt/lib/phantom' } Error: EACCES: permission denied, link 
'/tmp/phantomjs/phantomjs-2.1.1-linux-x86_64.tar.bz2-extract-
1507729380912/phantomjs-2.1.1-linux-x86_64' -> 
'/usr/lib/node_modules/markdown-pdf/node_modules/phantomjs-
prebuilt/lib/phantom'

As one can see, the error occurs when trying to link to /usr/lib/node_modules/markdown-pdf

However, the actual node_modules (containing actual modules) folder is located at /usr/lib/node_modules/npm/node_modules

Root is the only user on the System (debian-jessie), therefore permissions should not be a problem. I tried this (which also includes the option of creating a global directory manually), but to no avail. I would like it very much to keep it all in one (global) directory.

Thanks in advance for any help.

Upvotes: 2

Views: 997

Answers (1)

Fabian L
Fabian L

Reputation: 71

Got it fixed. Sort of.

Re-Installed nodejs

Set NODE_PATH (which was empty) to /usr/lib/node_modules

Used sudo npm install -g markdown-pdf --unsafe-perm=true --allow-root (see here)

Upvotes: 2

Related Questions