I have created the lambda application using node. The main issue I face is moving node_module with the npm build. Aws lambda excepts node modules also share the codeUri directory. So I use babel to move all my code .build directory including package.json. Which the best way to move the node_module to .build folder.
"scripts": {
"test": "cross-env NODE_ENV=test jest",
"build": "npm run clean:lib && mkdirp ./.build && npm run copyAndInstall && npm run build:babel",
"build:noclean": "npm run copyAndInstall && npm run build:babel && mkdirp ./.build ",
"build:lint": "eslint -c ./.eslintrc.json --ignore-path ./.eslintignore --ext .jsx,.js \"**\\*.+(js|jsx)\"",
"build:babel": "babel ./src --out-dir ./.build --ignore bower_components,coverage,node_modules,test,.dist,.build,temp,./start.js --comments false",
"clean:lib": "npm install rimraf && rimraf ./build",
"update:modules": "rimraf ./package-lock.json && rimraf ./node_modules && npm i",
"prepush": "npm run build:fix",
"build:fix": "eslint --fix -c ./.eslintrc.json --ignore-path ./.eslintignore --ext .jsx,.js \"**\\*.+(js|jsx)\"",
"copyAndInstall": "copyfiles package.json ./.build/
}
I even tried npm install --production --prefix ./.build" it give an error like refusing to install package with name under a package npm err! also called did you name your project the same as the dependency you're installing?