Skip to content

I had to add npm to dev dependencies #2

Closed

Description

@adamrneary

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.

Activity

  1. Tim-B commented on Dec 19, 2014

    @Tim-B
    Owner

    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.

  2. adamrneary commented on Dec 23, 2014

    @adamrneary
    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.

  3. taphat commented on Jan 16, 2015

    @taphat

    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

  4. Tim-B commented on Jan 17, 2015

    @Tim-B
    Owner

    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.

  5. gurre commented on Apr 5, 2015

    @gurre

    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.

  6. levbrie commented on May 23, 2015

    @levbrie

    +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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions