Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I had to add npm to dev dependencies #2

Closed
adamrneary opened this issue Dec 19, 2014 · 6 comments · Fixed by #13
Closed

I had to add npm to dev dependencies #2

adamrneary opened this issue Dec 19, 2014 · 6 comments · Fixed by #13

Comments

@adamrneary
Copy link

Strange issue here. I have npm installed globally, but when I followed your setup instructions, it was choking on the lambda_package task with:

Loading "lambda_package.js" tasks...ERROR
>> Error: Cannot find module 'npm'

I added npm to the dev dependencies inside your project, and everything ran fine. Not sure why that is if you didn't encounter the same issue. Again, I have npm installed globally, so it seems like a strange error.

@Tim-B
Copy link
Owner

Tim-B commented Dec 19, 2014

Are you able to post the Lambda function you were trying to run? That way I can test it and see if I get the issue myself. You could probably strip out any sensitive code so long as it still gives you that error.

@adamrneary
Copy link
Author

@Tim-B really sorry to leave this hanging. it's sort of a crazy outlier problem since i have npm installed globally. the lambda function is here: https://github.com/adventrtv/adventr-lambda-video/blob/master/src/video-events.js. again, when i manually add npm to the dev dependencies it runs fine, so i am really not sure what the issue is, but i have it circumvented on my end, so please feel free to close this issue if it's not something you want to worry about.

alternatively, it might be worth adding npm as a dependency in package.json just to avoid the matter if anyone else has the same problem, but it's probably not worth spending too much time hunting.

thanks again for posting the code. very useful.

@taphat
Copy link

taphat commented Jan 16, 2015

We also had to add npm to dev dependencies to get it to work. Same reason, we had npm installed globally. Thanks for posting this issue

@Tim-B
Copy link
Owner

Tim-B commented Jan 17, 2015

Hi @adamrneary and @taphat, sorry for the delay in following this up.

Would you mind putting the following in a file like test.js outside your project folder then run node test.js:

var npm = require("npm");

console.log(npm);

Do you get Cannot find module 'npm' when running that? For me I get a print out of the object but I suspect the npm module might not be installed globally for everyone.

FYI the packaging tests pass on travis without explicitly including the npm module in devDependencies but npm can be a bit finicky about include paths.

I'm thinking I might either be able to add npm explicitly to the grunt-aws-lambda dependencies to ensure it's included for everyone, or add a warning if the module can't be found so people know to add it to their devDependencies.

@gurre
Copy link

gurre commented Apr 5, 2015

I got this error too. Tried console.log(npm); and got:

module.js:340
    throw err;
      ^
Error: Cannot find module 'npm'
    at Function.Module._resolveFilename (module.js:338:15)
    at Function.Module._load (module.js:280:25)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)

sudo npm install npm --save-dev seems to be a quick fix.

@levbrie
Copy link

levbrie commented May 23, 2015

+1 (I also had to add npm to dev deps)

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

Successfully merging a pull request may close this issue.

5 participants