claudiajs / claudia

Deploy Node.js projects to AWS Lambda and API Gateway easily

Home Page:https://claudiajs.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cannot find module error during create

mythril opened this issue · comments

  • Expected behaviour:
    Lambda / ApiGateway is created and deployed

  • What actually happens:

$ yarn run create
yarn run v1.22.4
$ yarn run build && claudia create --region us-west-2 --api-module bin/api --policies policies/*.js
$ babel src --out-dir bin
src/api.js -> bin/api.js
packaging files npm install -q --no-audit --production
npm WARN deprecated chokidar@1.7.0: Chokidar 2 will break on node v14+. Upgrade to chokidar 3 with 15x less dependencies.
npm WARN deprecated core-js@2.6.11: core-js@<3 is no longer maintained and not recommended for usage due to the number of issues. Please, upgrade your dependencies to the actual version of core-js@3.
npm WARN deprecated fsevents@1.2.13: fsevents 1 will break on node v14+ and could be using insecure binaries. Upgrade to fsevents 2.
npm WARN deprecated resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated
npm WARN deprecated urix@0.1.0: Please see https://github.com/lydell/urix#deprecated
npm WARN lifecycle The node binary used for scripts is /tmp/yarn--1601325609711-0.36153428388618214/node but npm is using /usr/bin/node itself. Use the `--scripts-prepend-node-path` option to include the path for the node binary npm was executed with.

> core-js@2.6.11 postinstall /tmp/5EIwzH/kast-api-1.0.0-R36iJI/package/node_modules/core-js
> node -e "try{require('./postinstall')}catch(e){}"

npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.0.0 (node_modules/chokidar/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN kast-api@1.0.0 No description
npm WARN kast-api@1.0.0 No repository field.

added 306 packages from 197 contributors in 4.537s

2 packages are looking for funding
  run `npm fund` for details
validating package
Error: Cannot find module '/tmp/5EIwzH/kast-api-1.0.0-R36iJI/package/bin/api'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
    at Function.Module._load (internal/modules/cjs/loader.js:562:25)
    at Module.require (internal/modules/cjs/loader.js:692:17)
    at require (internal/modules/cjs/helpers.js:25:18)
    at validatePackage (/home/luke/.config/yarn/global/node_modules/claudia/src/tasks/validate-package.js:16:15)
    at initEnvVarsFromOptions.then.then.then.then.then.then.then.then.then.dir (/home/luke/.config/yarn/global/node_modules/claudia/src/commands/create.js:360:10)
    at process._tickCallback (internal/process/next_tick.js:68:7)
cannot require ./bin/api after clean installation. Check your dependencies.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
  • Link to a minimal, executable project that demonstrates the problem:
    I can't, but I can give you package.json:
{
  "name": "kast-api",
  "version": "1.0.0",
  "license": "UNLICENSED",
  "dependencies": {
    "aws-sdk": "^2.761.0",
    "babel-cli": "^6.26.0",
    "babel-plugin-inline-dotenv": "^1.6.0",
    "babel-preset-env": "^1.7.0",
    "claudia-api-builder": "^4.1.2",
    "fm.liveswitch": "^1.9.4-33424"
  },
  "babel": {
    "presets": [
      [
        "env",
        {
          "targets": {
            "node": "10"
          }
        }
      ]
    ],
    "plugins": [
      "inline-dotenv"
    ]
  },
  "scripts": {
    "build": "babel src --out-dir bin",
    "create": "yarn run build && claudia create --region us-west-2 --api-module bin/api --policies policies/*.js",
    "deploy": "yarn run build && claudia update"
  }
}

After the command is ran the referenced directory /tmp/5EIwzH/kast-api-1.0.0-R36iJI/package/bin/ does not exist, although /tmp/5EIwzH/kast-api-1.0.0-R36iJI/package/ does and seems to have the un-transpiled code

  • Steps to install the project:

  • Steps to reproduce the problem:

hmm, this seems to be caused by having bin in .gitignore