SWA CLI does not run because of imports
VojtechVokoun opened this issue · 3 comments
Are you accessing the CLI from the default port :4280
?
- No, I am using a different port number (
--port
) and accessing the CLI from that port - Yes, I am accessing the CLI from port
:4280
Make sure you are accessing the URL printed in the console when running
swa start
!
Describe the bug
I'm using the SWA as a part of a Teams Toolkit workflow. When I try to deploy the associated SWA, the workflow fails because of the failed imports.
The console lists an issue with the keyword 'with', which is weird considering my machines are running Node versions compatible with this keyword.
Tried to rollback my app to yesterday's deployed version, no luck there.
The error lists the following:
file:///opt/homebrew/lib/node_modules/@azure/static-web-apps-cli/dist/cli/index.js:22
import pkg from "../../package.json" with { type: "json" };
^^^^
SyntaxError: Unexpected token 'with'
at ESMLoader.moduleStrategy (node:internal/modules/esm/translators:119:18)
at ESMLoader.moduleProvider (node:internal/modules/esm/loader:468:14)
(the same error appears even after checking the version with swa --version
)
To Reproduce
Steps to reproduce the behavior:
- Go to Teams Toolkit
- Sign in to respective accounts
- Click on Deploy
- Choose ENV
- Confirm
- Wait for the build and let the yml workflow use
swa deploy ./build -d ${{SECRET_TAB_SWA_DEPLOYMENT_TOKEN}} --env production
(--verbose=silly
makes no difference) - See error
Expected behavior
The application to be deployed to Azure and the workflow to continue.
Desktop:
-
OS: macOS
-
Version: Sonoma 14.5 (23F79), Node 18.17.1, 20.8.1
-
OS: Windows
-
Version: 11 23H2 (22631.3880), Node 16.13.0
Additional context
Steps taken to try to fix the issue:
- change node version
- rollback to last deployed version
- delete node_modules
- install SWA CLI globally
- replace
with
byassert
, same error
It seems that somebody else made a bug report reporting the same issue – including it here: #871
I am having the same issue this morning with CLI version 2.0.0.
Upgrading to Node LTS v20.16.0 fixes the issue but I get a warning like so:
(node:7024) ExperimentalWarning: Importing JSON modules is an experimental feature and might change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
Unfortunately, local authentication is broken for me in 2.0.0 (windows 11, node 20.16.0), rolling back to 1.1.10 for now....
Dupe of #871