jonschlinkert / global-prefix

Get the npm global path prefix. Same code used internally by npm.
MIT License
28 stars 12 forks source link

Getting error with AWS Lambda #9

Closed bgkittrell closed 8 years ago

bgkittrell commented 8 years ago

I'm trying to run a sequelize migration from a Lambda and it's breaking when trying to get the global prefix. I believe it was working on version 0.1.2, but this new line that's been added in 0.1.3 is failing.

var userConfig = path.resolve(osenv.home(), '.npmrc');

Maybe Lambdas don't have a home directory? I'm having a hard time finding out. Any suggestions would be helpful. Attaching a screenshot of the trace.

screen_shot_2016-07-12_at_4 56 30_pm

jonschlinkert commented 8 years ago

hmm, good question. I'm definitely interested in the answer, @doowb any thoughts on this?

doowb commented 8 years ago

Maybe Lambdas don't have a home directory?

AFAIK, lambda is running a linux image but I don't know if there are restrictions on the home directory.

osenv is using os-homedir which is supposed to be a polyfill for older versions of node (which lambda used to only have node v0.10 available but now has node v4.

I think osenv is also used in npm so it should be working in lambda.

bgkittrell commented 8 years ago

I started a thread in the AWS forums. Hopefully they'll have some answers.

https://forums.aws.amazon.com/thread.jspa?threadID=235295

bgkittrell commented 8 years ago

FYI, I just ran osenv.home() in a lambda and it returns null.

It looks like I might be able to fix this by setting the PREFIX environment variable. What should that value be?

jonschlinkert commented 8 years ago

I'm afraid I won't be much help on this one. I'm not familiar with ASW lambda at all. @doowb?

I'll try to see if I know anyone that might be able to look at this too

doowb commented 8 years ago

I was googling around and haven't really found anything useful about lambda and the file system.

You could set the PREFIX environment variable to the npm path. You can find that by doing npm bin -g then removing the bin from the path.

bgkittrell commented 8 years ago

I set the PREFIX env variable to /usr and that addressed the issue.

Thanks for your help.