LoginSignup
0
0

More than 1 year has passed since last update.

AWS SAMの $ sam build で NpmExecutionError: NPM Failed が発生するときの対処法

Posted at

AWS SAMの $ sam build で NpmExecutionError: NPM Failed が発生するときの対処法

久しぶりにAWS SAM(AWS Serverless Application Model)CLIを利用してTypeScriptなLambdaを作成しようとしたところ、sam build で以下のようなエラーが発生しました。

$ sam build
Building codeuri: C:\Users\***\Desktop\sam-app\hello-world runtime: nodejs18.x metadata: {'BuildMethod': 'esbuild', 'BuildProperties': {'Minify': True, 'Target': 'es2020', 'Sourcemap': True, 'EntryPoints': ['app.ts']}} architecture: x86_64 functions: HelloWorldFunction
Traceback (most recent call last):
  File "runpy.py", line 194, in _run_module_as_main
  File "runpy.py", line 87, in _run_code
  File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\samcli\__main__.py", line 12, in <module>
    cli(prog_name="sam")
...(中略)...
  File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\aws_lambda_builders\workflows\nodejs_npm_esbuild\workflow.py", line 218, in _get_esbuild_subprocess
    npm_bin_path = subprocess_npm.run(["bin"], cwd=scratch_dir)
  File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\aws_lambda_builders\workflows\nodejs_npm\npm.py", line 85, in run
    raise NpmExecutionError(message=err.decode("utf8").strip())
aws_lambda_builders.workflows.nodejs_npm.npm.**NpmExecutionError: NPM Failed:**

環境

  • Windows 10 22H2
  • node v18.16.0, npm 9.6.5
  • SAM CLI → すみません、失念しました(再インストールしてしまった為)
  • sam init で作成したサンプルHello worldプロジェクト

対処法

AWS SAM CLIを再インストールする。

私はこれで直りました。

原因はハッキリわかりませんが、PCにインストールされているツールチェーンを整理したり、Pythonを再インストールしたせいな気がします。

以上、参考まで。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0