Skip to content
This repository has been archived by the owner on Jan 15, 2024. It is now read-only.

npm packages not being installed globally #174

Closed
spengilley opened this issue Jul 7, 2017 · 8 comments
Closed

npm packages not being installed globally #174

spengilley opened this issue Jul 7, 2017 · 8 comments
Assignees
Labels
Milestone

Comments

@spengilley
Copy link

Description

When I run a puppet module which installs nodes and then uses the new package nom provider to install grunt, bower and protractor, I am unable to use any of thee programs by typing their name on the command line

Steps to reproduce

# Install node
class { 'nodejs':
    version      => 'latest',
    make_install => false,
    require      => Class['base']
}

# Install node packages
package {['grunt', 'bower', 'protractor']:
    ensure          => present,
    provider        => 'npm',
    install_options => ['-g'],
    require         => Class['nodejs']
}

Type

grunt

Receive

-bash: grunt: command not found

Expected behavior

I expect grunt, bower and protractor to be recognised on the command line

Further details

On Debian/contrib-jessie64. Using Puppet version 3.78
I can see during the puppet run the following in the output

/Stage[main]/Dev/Package[bower]/ensure: created

I can also see that grunt is installed in the following places

/usr/local/node/node-v8.1.3/lib/node_modules/grunt
/usr/local/node/node-v8.1.3/lib/node_modules/grunt/lib/grunt
/usr/local/node/node-v8.1.3/lib/node_modules/grunt/node_modules/.bin/grunt
/usr/local/node/node-v8.1.3/lib/node_modules/grunt/node_modules/grunt-cli/bin/grunt
/usr/local/node/node-v8.1.3/lib/node_modules/grunt/bin/grunt
/usr/local/node/node-v8.1.3/bin/grunt

@Ma27
Copy link
Collaborator

Ma27 commented Jul 7, 2017

thanks for your bug report. Could you please tell me which version of this module you're using?

@spengilley
Copy link
Author

Hi there,

Of course. Version 2.0.0

@Ma27 Ma27 self-assigned this Jul 8, 2017
@Ma27 Ma27 added the bug label Jul 8, 2017
@Ma27
Copy link
Collaborator

Ma27 commented Jul 8, 2017

@spengilley you're right, I managed to reproduce this behavior and hope that I'll find some time next week :-)

@Ma27 Ma27 added this to the 2.0 milestone Jul 8, 2017
@Ma27
Copy link
Collaborator

Ma27 commented Jul 8, 2017

I just managed to research a little bit: it seems as no prefix is set which caused NPM to avoid setting create symlinks into the appropriate directory in $PATH.
In 1.9 we used an ugly script to add more /usr/local/node things into $PATH, so the prefix was unnecessary, but not this seems to cause issues.

I'll try to reserve some time to fix this next week, however a temporary workaround for you would be to create an exec resource in your manifest which runs the following command (assuming that /usr/local/bin is your install dir):

npm set prefix /usr/local -g

@spengilley
Copy link
Author

Thanks for the information and the work around!

@Ma27
Copy link
Collaborator

Ma27 commented Jul 12, 2017

@spengilley I created a bugfix in #175. Would be cool if you could test the changes locally in order to confirm that the patch works? :-)

Ma27 added a commit that referenced this issue Jul 12, 2017
Ma27 added a commit that referenced this issue Jul 12, 2017
@spengilley
Copy link
Author

Hi @Ma27 I can confirm that this worked wonderfully. I appreciate such a quick turn around.

Stephen

@Ma27 Ma27 closed this as completed in 2edfb6c Jul 13, 2017
@Ma27
Copy link
Collaborator

Ma27 commented Jul 13, 2017

patch landed in https://github.com/willdurand/puppet-nodejs/releases/tag/2.0.0-alpha3

thanks for reporting and for the feedback!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants