【以下的问题经过翻译处理】 我在Cloud9环境中尝试使用 https://github.com/fortejas/example-serverless-python-api,但是出现了以下错误。
我使用的设置命令如下:
mkdir sample-api
cd sample-api/
cdk init app --language typescript .
cd ~
git clone https://github.com/kasukur/example-serverless-python-api.git
ls -lrt example-serverless-python-api/
cp -rf example-serverless-python-api/lambda-api/ ~/environment/sample-api/.
cd ~/environment/sample-api/
Delete node_modules folder
Delete package-lock.json
npm i @aws-cdk/aws-lambda-python-alpha --force -g
ec2-user:~/environment/sample-api $ cdk deploy
错误为
ec2-user:~/environment/sample-api $ cdk synth
npm WARN exec The following package was not found and will be installed: ts-node
/home/ec2-user/.npm/_npx/1bf7c3c15bf47d04/node_modules/ts-node/src/index.ts:750
return new TSError(diagnosticText, diagnosticCodes);
^
TSError: ⨯ Unable to compile TypeScript:
bin/sample-api.ts:4:10 - error TS2305: Module '"../lib/sample-api-stack"' has no exported member 'SampleApiStack'.
4 import { SampleApiStack } from '../lib/sample-api-stack';
~~~~~~~~~~~~~~
at createTSError (/home/ec2-user/.npm/_npx/1bf7c3c15bf47d04/node_modules/ts-node/src/index.ts:750:12)
at reportTSError (/home/ec2-user/.npm/_npx/1bf7c3c15bf47d04/node_modules/ts-node/src/index.ts:754:19)
at getOutput (/home/ec2-user/.npm/_npx/1bf7c3c15bf47d04/node_modules/ts-node/src/index.ts:941:36)
at Object.compile (/home/ec2-user/.npm/_npx/1bf7c3c15bf47d04/node_modules/ts-node/src/index.ts:1243:30)
at Module.m._compile (/home/ec2-user/.npm/_npx/1bf7c3c15bf47d04/node_modules/ts-node/src/index.ts:1370:30)
at Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at Object.require.extensions.<computed> [as .ts] (/home/ec2-user/.npm/_npx/1bf7c3c15bf47d04/node_modules/ts-node/src/index.ts:1374:12)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12) {
diagnosticText: `\x1B[96mbin/sample-api.ts\x1B[0m:\x1B[93m4\x1B[0m:\x1B[93m10\x1B[0m - \x1B[91merror\x1B[0m\x1B[90m TS2305: \x1B[0mModule '"../lib/sample-api-stack"' has no exported member 'SampleApiStack'.\n` +
'\n' +
"\x1B[7m4\x1B[0m import { SampleApiStack } from '../lib/sample-api-stack';\n" +
'\x1B[7m \x1B[0m \x1B[91m ~~~~~~~~~~~~~~\x1B[0m\n',
diagnosticCodes: [ 2305 ]
}
Subprocess exited with error 1
有人能帮忙看看这是怎么回事吗?
谢谢!