Customizing metro.config.js in an Expo Snack project

30 Views Asked by At

I need to customize metro config in an expo snack project so that it supports .cjs files. Here's the code in my metro.config.js file:

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

const config = getDefaultConfig(__dirname);

config.resolver.sourceExts.push(
  // Adds support for `.cjs` files
  'cjs'
);

module.exports = config;

Unfortunately, Expo Snack can't resolve the dependency for expo/metro-config. When I click "add dependency" on the first appearence of the error message, it adds the line "expo/metro-config": "",* to my package.json file, then fails to resole this dependency. I've also tried manually adding the version number that my local project uses, 0.17.4, to no avail.

I'm new to expo and metro - how might I be able to get this to work?

Many thanks in advance

0

There are 0 best solutions below