Skip to content

Compatibility with Node v22 #70

@pcorpet

Description

@pcorpet

Bug description
When using node v22.9.0, importing the package raises an error

To Reproduce
Create a simple repro-bug-assert.mjs in a package with latest version of this package:

import 'storybook-addon-remix-react-router'

Check that you have installed node v22+

$ node --version
v22.2.0

Run the test file:

$ node ./repro-bug-assert.mjs
file:///.../node_modules/storybook-addon-remix-react-router/dist/index.js:3
import de from '../package.json' assert { type: 'json' };

SyntaxError: Unexpected identifier 'assert'

Additional context
This is because of nodejs/node#52104 which removed the support of assert in node v22+, and that the builded ESM version of the package contains

import { makeDecorator, addons } from '@storybook/preview-api';
import P, { useState, useMemo, useCallback, useRef } from 'react';
import de from '../package.json' assert { type: 'json' };

Replacing assert with with works.

Environment

Storybook Environment Info:

  System:
    OS: macOS 14.6.1
    CPU: (10) arm64 Apple M2 Pro
    Shell: 3.2.57 - /bin/bash
  Binaries:
    Node: 22.2.0 - /opt/homebrew/bin/node
    Yarn: 4.0.1 - /opt/homebrew/bin/yarn <----- active
    npm: 10.7.0 - /opt/homebrew/bin/npm
    pnpm: 9.3.0 - /opt/homebrew/bin/pnpm
  Browsers:
    Chrome: 128.0.6613.138
    Safari: 18.0
  npmPackages:
    @storybook/addon-designs: 8.0.3 => 8.0.3 
    @storybook/addon-essentials: 8.3.1 => 8.3.1 
    @storybook/addon-interactions: 8.3.1 => 8.3.1 
    @storybook/addon-links: 8.3.1 => 8.3.1 
    @storybook/addon-themes: 8.3.1 => 8.3.1 
    @storybook/blocks: 8.3.1 => 8.3.1 
    @storybook/channels: 8.3.1 => 8.3.1 
    @storybook/components: 8.3.1 => 8.3.1 
    @storybook/core-events: 8.3.1 => 8.3.1 
    @storybook/manager-api: 8.3.1 => 8.3.1 
    @storybook/preview-api: 8.3.1 => 8.3.1 
    @storybook/react: 8.3.1 => 8.3.1 
    @storybook/react-vite: 8.3.1 => 8.3.1 
    @storybook/theming: 8.3.1 => 8.3.1 
    eslint-plugin-storybook: ^0.8.0 => 0.8.0 
    storybook: 8.3.1 => 8.3.1 
    storybook-addon-remix-react-router: 3.0.0 => 3.0.0 

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions