Skip to content

ReferenceError: process is not defined when using Shapediver #2858

@sebastian-meckovski

Description

@sebastian-meckovski

What is the location of your example repository?

https://github.com/sebastian-meckovski/hydrogen-shapediver-test

Which package or tool is having this issue?

Shapediver

What version of that package or tool are you using?

3.9.6

What version of Remix are you using?

Remix: 2.16.1
Hydrogen: 2025.1.3

Steps to Reproduce

  • scaffold project
    npm create @shopify/hydrogen@latest

  • Install Shapediver NPM package
    npm i @shapediver/viewer.session

  • Paste this code snippet to products page inside Product component. This should only run on client side:

  useEffect(() => {
    const init = async () => {
      try {
        const {createSession} = await import('@shapediver/viewer.session');

        const session = await createSession({
          ticket: 'ticketId',
          modelViewUrl: 'modelViewUrl',
        });
      } catch (error) {
        console.error('Error initializing the session or viewport:', error);
      }
    };
    init();
  }, []);

Expected Behavior

It should attempt to create a session in the client, this can be checked in the browser dev tools console:

Initializing session...
_index.tsx:21 Powered by:
   _____  __                         ____   _                   
  / ___/ / /_   ____ _ ____   ___   / __ \ (_)_   __ ___   _____
  \__ \ / __ \ / __ '// __ \ / _ \ / / / // /| | / // _ \ / ___/
 ___/ // / / // /_/ // /_/ //  __// /_/ // / | |/ //  __// /    
/____//_/ /_/ \__,_// .___/ \___//_____//_/  |___/ \___//_/     
                   /_/                                          
ShapeDiver Viewer 3, Version 3.9.6
Visit us at https://shapediver.com/ and find out more!

_index.tsx:25 Session created: SessionApi {}

Actual Behavior

When CreateSession is invoked, the following error appears in the browser dev tools console:

Image

Important notes:

  • This was not happening on hydrogen version 2025.1.2 and remix 2.15.3. Code from this repository works as expected
  • The older version is deployed here. Can be tested by clicking the settings cog next to the picture. As a result a 3D model should appear instead of an image.
  • I also tried to reproduce it in simple Remix + Vite template in this branch. Shapediver works as expected there
  • This is a follow up from this issue as it might be related. The original issue was resolved by doing dynamic imports and tweaking vite.config.ts
  • Shapediver should only run on client side, it should never be run on the server side at all

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions