Skip to content

[bug]: upwardPath not found error #4352

@zeina99

Description

@zeina99

Describe the bug

Whenever trying to launch an upward-js server using the command npx upward-js-server I get an error saying the following:

Error: upwardPath is required
    at createUpwardServer (/home/pwa/node_modules/@magento/upward-js/lib/createUpwardServer.js:47:15)
    at Object.<anonymous] (/home/pwa/node_modules/@magento/upward-js/bin/server:5:40)
    at Module._compile (node:internal/modules/cjs/loader:1155:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1209:10)
    at Module.load (node:internal/modules/cjs/loader:1033:32)
    at Function.Module._load (node:internal/modules/cjs/loader:868:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
    at node:internal/main/run*main*module:22:47

I have already provided the required environment variables in the .env file
UPWARD*JS_UPWARD*PATH=dist/upward.yml
UPWARD*JS_BIND*LOCAL=true

To reproduce

Steps to reproduce the behavior:

  1. Create a sample pwa project
  2. Setup upward-js variables in the .env file
  3. Launch the upward-js server using the command npx upward-js-server
  4. Error saying upwardPath is required will show up.

Expected behavior

I expect the upward js server to launch given that the env variables are provided.

Screenshots

If applicable, add screenshots to help explain your problem.

Possible solutions

I did try to debug the issue and check that .env variables set in the file are being read.
In the file /bin/server I added a console.log(config); and this was the output:

{{ [Function: transformer] { fromEnv: [Function (anonymous)], toEnv: [Function (anonymous)> } }}
And this is not the input createUpwardServer() expects in createUpwardServer.js
After manually editing the config object to be
{{ const config = { upwardPath: process.env.UPWARD*JS_UPWARD*PATH || './upward.yml', bindLocal: process.env.UPWARD*JS_BIND*LOCAL === 'true', port: 8000), host: '0.0.0.0', logUrl: true }; }}

Running npx upward-js-server worked!

Debug Report

yarn run v1.22.22
$ buildpack generate-build-report
  ℹ  Generating build report for kaneen3@13.3.0. This may take a moment.

  ℹ  Inspecting Dependencies
    Found 10 @magento dependencies in yarn.lock
    @magento/pwa-buildpack @ 11.4.3
    @magento/upward-js @ 5.3.2
    @adobe/apollo-link-mutation-queue @ 1.0.2
    @magento/babel-preset-peregrine @ 1.2.2
    @magento/eslint-config @ 1.5.3
    @magento/pagebuilder @ 8.2.1
    @magento/peregrine @ 13.2.1
    @magento/pwa-theme-venia @ 1.4.0
    @magento/upward-security-headers @ 1.0.11
    @magento/venia-ui @ 10.3.0

  ℹ  Inspecting Magento Backend
Browserslist: caniuse-lite is outdated. Please run:
  npx update-browserslist-db@latest
  Why you should do it regularly: https://github.com/browserslist/update-db#readme
Intercept custom JS done
Intercept custom CSS done
    Not using sample backend.
    Backend is UP!

  ℹ  Inspecting System
    OS: #78~20.04.1-Ubuntu SMP Wed Oct 9 22:05:22 UTC 2024
    Node Version: v16.18.1
    NPM Version: 8.19.2

Please complete the following device information:

  • Device <e.g. iPhone6, PC, Mac, Pixel3]:
  • Browser [e.g. Chrome, Safari]:
  • Browser Version [e.g. 22]:
  • Magento Version [e.g Adobe Commerce 2.4]:

[!-- Complete the following sections to help us apply appropriate labels! --]

Please let us know what packages this bug is in regards to:

  • venia-concept
  • venia-ui
  • pwa-buildpack
  • peregrine
  • pwa-devdocs
  • upward-js
  • upward-spec
  • [ > create-pwa

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions