Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Aug 01 2016 23:48
    @gojko banned @codepreneur
hackerunet
@hackerunet
it has to be: npm install --prefix <path/to/prefix_folder>
and it will install in <path/to/prefix>/node_modules
Kevin Coleman
@kevintechie
npm is installed globally and functions normally.
I cleaned my npm chache, but that did not make a difference.
Installing npm claudia -g (from npm repository) sets up a symlink in the npm bin directory to the global install of claudia. When in the claudia project folder and I install claudia, no such link is established. It appears to just do the same thing as a plain npm install which just installs the project dependencies.
I'm on npm 6.3.10 and node 10.16.0. I use NVM to manage my node versions. I'm developing on linux.
hackerunet
@hackerunet
did you try with --prefix ?
Kevin Coleman
@kevintechie
More info: When I mentioned above that I had command not fount, it wasn't in reference to running the npm install ../claudia command. It was that after I ran the install, when I type claudia I get command not found.
Gojko Adzic
@gojko
@kevintechie when you install with a local dependency (../claudia), the command will not be in your system exec path
however, NPM adds it to the NPM binary path
so for example, if you have two dirs, work/claudia and work/client; and inside the client you do npm install ../claudia then when you are inside the client dir, and it's a NPM project, you should be able to execute $(npm bin)/claudia
npm bin will return the path to the current NPM binary dir for the active project based on package json
and claudia should be linked there as a binary
you can also add scripts directly to your package.json, eg
{
  "scripts": {
    "deploy": "claudia create --name ..."
  }
}
and then you will be able to do npm run deploy
npm scripts execute with the PATH variable including the current project NPM bin path
Kevin Coleman
@kevintechie
When I do execute npm install ../claudia in the client, I get the same warnings and error as when I tried to install globally. I get a bunch of skipping optional dependency warnings and then an error trying to rename .../node_modules/.staging/ieee754-ed3f2bf2 to .../claudia/node_modules/aws-sdk/node_modules/ieee754
Gojko Adzic
@gojko
@kevintechie your npm modules may be borked. I suggest removing node_modules in the test project (and the claudia working dir), and removing any package-lock.json files you have in those two dirs; then try again
Kevin Coleman
@kevintechie
ok, i'll give it a try. Thanks for your continued help!
Kevin Coleman
@kevintechie
I'm still getting the error. I started with a fresh clone of claudia, and then npm installed it. Then I created a blank test client project. In the test project I did an npm init and added a hello world index.js file. I'm still getting the same errors when executing npm install ../claudia
Kevin Coleman
@kevintechie
Well, I got it to work. The key was to NOT do an npm install after cloning claudia.
Chant Long
@chantlong_twitter

@gojko I do have an AWS_ROLE_ARN for other purposes not for Claudia.
The command I used to deploy is

claudia create --name my-lambda --version development --region ap-northeast-1 --handler index.handler --policies policies --set-env-from-json env.json.development --timeout 240 --runtime nodejs8.10 --memory 1536

which works in claudia 5.1 but not 5.6.

Gojko Adzic
@gojko
@chantlong_twitter we added something in 5.6 that lets people use STS tokens and assumed roles, but that picks up AWS_ROLE_ARN from the environment and thinks that you want to use STS if it is defined
that seems like a wrong assumption
to get 5.6 to work, you'll need to clear out that env var
can you help me understand your use case so I fix it - what do you use that env var for instead?
@kevintechie weird, but thanks for letting me know, I can add that to developer docs
Ross Coundon
@rcoundon

I'm trying to package up my typescript lambda project using claudia-api-builder as the entrypoint.
The entrypoint is defined in index.js (as I don't think there's native typescript support yet)

package.json
|--src
  |--functions
    index.js
    handler.ts
|--node_modules
|--build

I'm trying to deploy using this command:

claudia create \
  --region eu-west-2 \
  --api-module build/functions/handler \
  --keep

All the compiled files, including the index.js are written into the build folder which mirrors the structure in src.
However, I get an error

Cannot find module '/var...../package/build/functions/handler

and then:

cannot require ./build/functions/handler after clean installation. Check your dependencies.

Is it possible to structure things in this way? If so, what should my create command be?

Gojko Adzic
@gojko
@rcoundon do claudia pack and see what gets included in the package. Your NPM project setup might be ignoring the build directory
You can see how to set up files to be included or excluded here https://claudiajs.com/tutorials/packaging.html
Ross Coundon
@rcoundon
That was it - thank-you
Simran Singh
@esimran
when I run claudia create --handler lambda.handler --deploy-proxy-api --region us-east-1 I get an Unexpected token { error, I'm using an express app with babel. Any advice on how to fix this? Do i have to transpile the code using webpack first?
Gojko Adzic
@gojko
@esimran try running require('./lambda') from node in that directory
the problem suggests you have a syntax error somewhere
hackerunet
@hackerunet
hi there, I have a question, how can I require an external config file to create a lambda function with claudia?
const jwt = require('jsonwebtoken');
const config = require('../config/config');

exports.auth = function auth(event, context, callback) {
    'use strict';
    console.log('got event', event);
I'm currently getting a config module not found.
"Cannot find module '../config/config'
Ross Coundon
@rcoundon
I'd just like to say, thanks for creating ClaudiaJs. It truly simplifies what can be a very complicated topic of deployment in regards to SAM and/or CloudFormation.
Gojko Adzic
@gojko
@rcoundon thanks!
hackerunet
@hackerunet
if creating microservices isn't any way to avoid handling multiple configurations for each microservice? I really need to have 2 environments for testing and apparently I cannot reference any centralized configuration if the file is out of the project, is there any workaround for this?
Gojko Adzic
@gojko
@hackerunet you can use AWS System Manager to store parameters (check the parameter store) or use env variables or stage variables for APIs
it includes an example of how to include different config files for different environments
hackerunet
@hackerunet
ok, another question, I received an error deploying to AWS, it says the lambda function already exists, so, the main problem is, how can I delete a lambda function that is not listed in the functions list in AWS? claudia complains it exist but I see nothing in AWS
hackerunet@kerberobot:~/Projects/sp-api/auth$ claudia create --name auth --region us-east-1 --handler index.auth
packaging files npm install -q --no-audit --production
npm WARN auth@1.0.0 No description

creating Lambda lambda.setupRequestListeners
{ ResourceConflictException: Function already exist: auth
hackerunet
@hackerunet
sorry for my estupidity, I will never ask anything again.
thanks @gojko
the issue was me checking in the wrong region in AWS console. I'm an idiot.
Ross Coundon
@rcoundon
Hi @stojanovic - Is the best place to report errata and issues encountered with your book on the Manning site or here?
Slobodan Stojanović
@stojanovic
On the Manning site, please. Thanks :)
Kevin Coleman
@kevintechie
Hello, @gojko. I finally submitted a pr with validation and tests for adding authorization scopes to API Gateway methods.
Kevin Coleman
@kevintechie
While adding the authorizationScopes support, I noticed that you don't have "root": true in your .eslintrc.json file. Is this intentional? If not, it would be nice to have so that your config is not augmented by an eslint config higher in the project path.
Slobodan Stojanović
@stojanovic
It’s probably useful to add root: true, thanks for the suggestion