aws-lambda-nodejs empties node_modules folder when building functions in different directories
aws-lambda-nodejs empties node_modules folder when building functions in different directories
Reproduction Steps
mkdir func
cd func
npm init
touch index.ts
cd ..
mkdir cdk
cd cdk
cdk init --language typescript
this is the cdk-stack.ts
import * as cdk from '@aws-cdk/core';
import lambda = require('@aws-cdk/aws-lambda-nodejs');
export class CdkStack extends cdk.Stack {
constructor(scope: cdk.Construct, id: string, props?: cdk.StackProps) {
super(scope, id, props);
new lambda.NodejsFunction(this, 'MyFunction', {
entry: '../func/lam/index.ts',
handler: 'handler'
});
}
}
Error Log
bin/cdk.ts:3:22 - error TS2307: Cannot find module '@aws-cdk/core'.
When I check the node_modules folder in the cdk directory only has a typescript folder
Environment
- **CLI Version :
- **Framework Version: 1.27.0
- **OS : macos
- **Language : typescript
Other
This is :bug: Bug Report
hey @msimpsonnz, I'm not able to reproduce the error.
From which folder are you running cdk synth?
When I check the node_modules folder in the cdk directory only has a typescript folder
I think that it should be the case for your func folder.
Did you install parcel-bundler locally in the cdk folder?

Thanks, I’m running synth from the cdk folder Yep I have install the pre reqs
Can you share your exact folder structure and both package.json files? Is aws-cdk installed globally? Does parcel build successfully? Do you see a index.js file in func/.build/<hash>/?
Looks like it was NPM upgraded to latest version and is good