Skip to content
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

SWA CLI does not run because of imports #872

Closed
1 of 2 tasks
VojtechVokoun opened this issue Jul 24, 2024 · 3 comments
Closed
1 of 2 tasks

SWA CLI does not run because of imports #872

VojtechVokoun opened this issue Jul 24, 2024 · 3 comments
Labels
status: duplicate This issue or pull request already exists

Comments

@VojtechVokoun
Copy link

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:

  1. Go to Teams Toolkit
  2. Sign in to respective accounts
  3. Click on Deploy
  4. Choose ENV
  5. Confirm
  6. 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)
  7. 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 by assert, same error
@VojtechVokoun
Copy link
Author

It seems that somebody else made a bug report reporting the same issue – including it here: #871

@peter-mskeng
Copy link

peter-mskeng commented Jul 24, 2024

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....

@adrianhall adrianhall added the status: duplicate This issue or pull request already exists label Jul 24, 2024
@adrianhall
Copy link
Member

Dupe of #871

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

3 participants