Skip to content

RN + SES: TypeError: undefined is not a function (near '...globalThis.process.on...') #11

@leotm

Description

@leotm

Follow-up to


npx react-native@0.66.5 init RN0665 --version 0.66.5

yarn add ses

// index.js

import 'ses'; // added
import {AppRegistry} from 'react-native';
import App from './App';
import {name as appName} from './app.json';

lockdown({consoleTaming: 'unsafe'}); // added

AppRegistry.registerComponent(appName, () => App);
// metro.config.js

const {getDefaultConfig} = require('metro-config');

module.exports = (async () => {
  const {
    resolver: {sourceExts},
  } = await getDefaultConfig();
  return {
    transformer: {
      getTransformOptions: async () => ({
        transform: {
          experimentalImportSupport: false,
          inlineRequires: true,
        },
      }),
    },
    resolver: {
      sourceExts: [...sourceExts, 'cjs'],
    },
  };
})();
// babel.config.js

module.exports = {
  ignore: [/ses\.cjs/],
  presets: ['module:metro-react-native-babel-preset'],
};

yarn start --reset-cache

yarn start ios

Result:

 ERROR  TypeError: undefined is not a function (near '...globalThis.process.on...')

Screenshot 2023-02-28 at 15 47 55

(this|global|globalThis|window).process in our RN realm contains only {"env": {"NODE_ENV": "development"}}

So our Node API methods (on/exit/abort/etc) are missing https://nodejs.org/api/process.html#process (being an instance of EventEmitter)

Which we now need to be added to our vanilla RN PoC

First seen in

  • MMM: RN 0.66.5 + SES 0.18.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions