-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug: sam sync crashes when a "prepare" statement is in package.json #6835
Comments
Hi @maplion, Thanks for opening the issue! I wasn't able to reproduce the error when I tried running |
Here is the error I receive: npm ERR! A complete log of this run can be found in: C:\Users\<user>\AppData\Local\npm-cache\_logs\2024-03-15T19_55_36_822Z-debug-0.log
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\Lib\site-packages\samcli\lib\sync\watch_manager.py", line 257, in _execute_infra_sync
infra_sync_result = self._execute_infra_context(first_sync)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\Lib\site-packages\samcli\lib\sync\watch_manager.py", line 187, in _execute_infra_context
return self._infra_sync_executor.execute_infra_sync(first_sync)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\Lib\site-packages\samcli\lib\sync\infra_sync_executor.py", line 168, in execute_infra_sync
self._build_context.run()
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\Lib\site-packages\samcli\commands\build\build_context.py", line 332, in run
raise UserException(str(ex), wrapped_from=wrapped_from) from ex
samcli.commands.exceptions.UserException: NodejsNpmEsbuildBuilder:NpmInstall - NPM Failed: npm WARN config production Use `--omit=dev` instead.
npm WARN deprecated querystring@0.2.0: The querystring API is considered Legacy. new code should use the URLSearchParams API instead.
'husky' is not recognized as an internal or external command,
operable program or batch file.
npm ERR! code 1
npm ERR! path C:\Users\<user>\AppData\Local\Temp\tmp8k6l4ov8
npm ERR! command failed
npm ERR! command C:\Windows\system32\cmd.exe /d /s /c husky |
Spoke on slack, summarizing the workarounds here for visibility. When SAM CLI builds a node project it does not download the dev dependencies which is what causes the command not found error. specifying the |
I ended up using the |
|
Description:
sam sync
crashes on loading when there is a "prepare" statement within "scripts" section of the package.jsonContext:
I'm using the npm husky library (https://typicode.github.io/husky/get-started.html) as an "automated" way to have things done at commit time consistently among my team and it currently seems to break sam sync because of the "prepare": "husky" in the package.json that is required to be there to ensure everyone on the team installs it at least once for each repo/project.
Steps to reproduce:
npm install --save-dev husky
npx husky init
-- you should see a"prepare": "husky"
added as a final "scripts" line within the package.json (if not, add it manually).Observed result:
sam sync crashes with a Python error during startup -- this can be resolved by temporarily removing the prepare statement and starting again.
Expected result:
I expect sam sync to start as normal and ignore the prepare statement
Additional environment details (Ex: Windows, Mac, Amazon Linux etc)
sam --version
: 1.108.0The text was updated successfully, but these errors were encountered: