Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SyntaxError: index.js: Cannot find module 'babel-plugin-module-resolver' #448

Open
m8tec opened this issue Dec 6, 2024 · 2 comments
Open

Comments

@m8tec
Copy link

m8tec commented Dec 6, 2024

I'm using this package for my react native app.
It works fine with development builds and even for iOS release,
but I can't get it to work when I try to create an Android app bundle.

Anybody had the same issue?

Logs:
[RUN_GRADLEW] > Task :app:createBundleReleaseJsAndAssets [RUN_GRADLEW] Starting Metro Bundler [RUN_GRADLEW] warning: Bundler cache is empty, rebuilding (this may take a minute) [RUN_GRADLEW] (node:10834) [DEP0040] DeprecationWarning: The punycodemodule is deprecated. Please use a userland alternative instead. [RUN_GRADLEW] (Usenode --trace-deprecation ... to show where the warning was created) [RUN_GRADLEW] Android Bundling failed 144ms index.js (1 module) [RUN_GRADLEW] SyntaxError: index.js: Cannot find module 'babel-plugin-module-resolver' [RUN_GRADLEW] Require stack: [RUN_GRADLEW] - /private/var/folders/3_/8m8v8w1x5vvb5ljy5vwvhzkh0000gn/T/eas-build-local-nodejs/8bb8125d-ac16-4133-9f36-5054343383d4/build/node_modules/@babel/core/lib/config/files/plugins.js [RUN_GRADLEW] - /private/var/folders/3_/8m8v8w1x5vvb5ljy5vwvhzkh0000gn/T/eas-build-local-nodejs/8bb8125d-ac16-4133-9f36-5054343383d4/build/node_modules/@babel/core/lib/config/files/index.js [RUN_GRADLEW] - /private/var/folders/3_/8m8v8w1x5vvb5ljy5vwvhzkh0000gn/T/eas-build-local-nodejs/8bb8125d-ac16-4133-9f36-5054343383d4/build/node_modules/@babel/core/lib/index.js [RUN_GRADLEW] - /private/var/folders/3_/8m8v8w1x5vvb5ljy5vwvhzkh0000gn/T/eas-build-local-nodejs/8bb8125d-ac16-4133-9f36-5054343383d4/build/node_modules/@expo/metro-config/build/transform-worker/metro-transform-worker.js [RUN_GRADLEW] - /private/var/folders/3_/8m8v8w1x5vvb5ljy5vwvhzkh0000gn/T/eas-build-local-nodejs/8bb8125d-ac16-4133-9f36-5054343383d4/build/node_modules/@expo/metro-config/build/transform-worker/transform-worker.js [RUN_GRADLEW] - /private/var/folders/3_/8m8v8w1x5vvb5ljy5vwvhzkh0000gn/T/eas-build-local-nodejs/8bb8125d-ac16-4133-9f36-5054343383d4/build/node_modules/metro/src/DeltaBundler/Worker.flow.js [RUN_GRADLEW] - /private/var/folders/3_/8m8v8w1x5vvb5ljy5vwvhzkh0000gn/T/eas-build-local-nodejs/8bb8125d-ac16-4133-9f36-5054343383d4/build/node_modules/metro/src/DeltaBundler/Worker.js [RUN_GRADLEW] - /private/var/folders/3_/8m8v8w1x5vvb5ljy5vwvhzkh0000gn/T/eas-build-local-nodejs/8bb8125d-ac16-4133-9f36-5054343383d4/build/node_modules/jest-worker/build/workers/processChild.js [RUN_GRADLEW] Make sure that all the Babel plugins and presets you are using [RUN_GRADLEW] are defined as dependencies or devDependencies in your package.json [RUN_GRADLEW] file. It's possible that the missing plugin is loaded by a preset [RUN_GRADLEW] you are using that forgot to add the plugin to its dependencies: you [RUN_GRADLEW] can workaround this problem by explicitly adding the missing package [RUN_GRADLEW] to your top-level package.json. [RUN_GRADLEW] Error: Cannot find module 'babel-plugin-module-resolver' [RUN_GRADLEW] Require stack: [RUN_GRADLEW] - /private/var/folders/3_/8m8v8w1x5vvb5ljy5vwvhzkh0000gn/T/eas-build-local-nodejs/8bb8125d-ac16-4133-9f36-5054343383d4/build/node_modules/@babel/core/lib/config/files/plugins.js [RUN_GRADLEW] - /private/var/folders/3_/8m8v8w1x5vvb5ljy5vwvhzkh0000gn/T/eas-build-local-nodejs/8bb8125d-ac16-4133-9f36-5054343383d4/build/node_modules/@babel/core/lib/config/files/index.js [RUN_GRADLEW] - /private/var/folders/3_/8m8v8w1x5vvb5ljy5vwvhzkh0000gn/T/eas-build-local-nodejs/8bb8125d-ac16-4133-9f36-5054343383d4/build/node_modules/@babel/core/lib/index.js [RUN_GRADLEW] - /private/var/folders/3_/8m8v8w1x5vvb5ljy5vwvhzkh0000gn/T/eas-build-local-nodejs/8bb8125d-ac16-4133-9f36-5054343383d4/build/node_modules/@expo/metro-config/build/transform-worker/metro-transform-worker.js [RUN_GRADLEW] - /private/var/folders/3_/8m8v8w1x5vvb5ljy5vwvhzkh0000gn/T/eas-build-local-nodejs/8bb8125d-ac16-4133-9f36-5054343383d4/build/node_modules/@expo/metro-config/build/transform-worker/transform-worker.js [RUN_GRADLEW] - /private/var/folders/3_/8m8v8w1x5vvb5ljy5vwvhzkh0000gn/T/eas-build-local-nodejs/8bb8125d-ac16-4133-9f36-5054343383d4/build/node_modules/metro/src/DeltaBundler/Worker.flow.js [RUN_GRADLEW] - /private/var/folders/3_/8m8v8w1x5vvb5ljy5vwvhzkh0000gn/T/eas-build-local-nodejs/8bb8125d-ac16-4133-9f36-5054343383d4/build/node_modules/metro/src/DeltaBundler/Worker.js [RUN_GRADLEW] - /private/var/folders/3_/8m8v8w1x5vvb5ljy5vwvhzkh0000gn/T/eas-build-local-nodejs/8bb8125d-ac16-4133-9f36-5054343383d4/build/node_modules/jest-worker/build/workers/processChild.js [RUN_GRADLEW] Make sure that all the Babel plugins and presets you are using [RUN_GRADLEW] are defined as dependencies or devDependencies in your package.json [RUN_GRADLEW] file. It's possible that the missing plugin is loaded by a preset [RUN_GRADLEW] you are using that forgot to add the plugin to its dependencies: you [RUN_GRADLEW] can workaround this problem by explicitly adding the missing package [RUN_GRADLEW] to your top-level package.json. [RUN_GRADLEW] at Module._resolveFilename (node:internal/modules/cjs/loader:1142:15) [RUN_GRADLEW] at resolve (node:internal/modules/helpers:190:19) [RUN_GRADLEW] at tryRequireResolve (/private/var/folders/3_/8m8v8w1x5vvb5ljy5vwvhzkh0000gn/T/eas-build-local-nodejs/8bb8125d-ac16-4133-9f36-5054343383d4/build/node_modules/@babel/core/lib/config/files/plugins.js:121:11) [RUN_GRADLEW] at resolveStandardizedNameForRequire (/private/var/folders/3_/8m8v8w1x5vvb5ljy5vwvhzkh0000gn/T/eas-build-local-nodejs/8bb8125d-ac16-4133-9f36-5054343383d4/build/node_modules/@babel/core/lib/config/files/plugins.js:155:19) [RUN_GRADLEW] at resolveStandardizedName (/private/var/folders/3_/8m8v8w1x5vvb5ljy5vwvhzkh0000gn/T/eas-build-local-nodejs/8bb8125d-ac16-4133-9f36-5054343383d4/build/node_modules/@babel/core/lib/config/files/plugins.js:170:12) [RUN_GRADLEW] at loadPlugin (/private/var/folders/3_/8m8v8w1x5vvb5ljy5vwvhzkh0000gn/T/eas-build-local-nodejs/8bb8125d-ac16-4133-9f36-5054343383d4/build/node_modules/@babel/core/lib/config/files/plugins.js:52:20) [RUN_GRADLEW] at loadPlugin.next (<anonymous>) [RUN_GRADLEW] at createDescriptor (/private/var/folders/3_/8m8v8w1x5vvb5ljy5vwvhzkh0000gn/T/eas-build-local-nodejs/8bb8125d-ac16-4133-9f36-5054343383d4/build/node_modules/@babel/core/lib/config/config-descriptors.js:140:16) [RUN_GRADLEW] at createDescriptor.next (<anonymous>) [RUN_GRADLEW] at evaluateSync (/private/var/folders/3_/8m8v8w1x5vvb5ljy5vwvhzkh0000gn/T/eas-build-local-nodejs/8bb8125d-ac16-4133-9f36-5054343383d4/build/node_modules/gensync/index.js:251:28) [RUN_GRADLEW] at /private/var/folders/3_/8m8v8w1x5vvb5ljy5vwvhzkh0000gn/T/eas-build-local-nodejs/8bb8125d-ac16-4133-9f36-5054343383d4/build/node_modules/gensync/index.js:31:34 [RUN_GRADLEW] at Array.map (<anonymous>) [RUN_GRADLEW] at Function.sync (/private/var/folders/3_/8m8v8w1x5vvb5ljy5vwvhzkh0000gn/T/eas-build-local-nodejs/8bb8125d-ac16-4133-9f36-5054343383d4/build/node_modules/gensync/index.js:31:22) [RUN_GRADLEW] at Function.all (/private/var/folders/3_/8m8v8w1x5vvb5ljy5vwvhzkh0000gn/T/eas-build-local-nodejs/8bb8125d-ac16-4133-9f36-5054343383d4/build/node_modules/gensync/index.js:210:24) [RUN_GRADLEW] at Generator.next (<anonymous>) [RUN_GRADLEW] at createDescriptors (/private/var/folders/3_/8m8v8w1x5vvb5ljy5vwvhzkh0000gn/T/eas-build-local-nodejs/8bb8125d-ac16-4133-9f36-5054343383d4/build/node_modules/@babel/core/lib/config/config-descriptors.js:102:41) [RUN_GRADLEW] at createDescriptors.next (<anonymous>) [RUN_GRADLEW] at createPluginDescriptors (/private/var/folders/3_/8m8v8w1x5vvb5ljy5vwvhzkh0000gn/T/eas-build-local-nodejs/8bb8125d-ac16-4133-9f36-5054343383d4/build/node_modules/@babel/core/lib/config/config-descriptors.js:99:17) [RUN_GRADLEW] at createPluginDescriptors.next (<anonymous>) [RUN_GRADLEW] at /private/var/folders/3_/8m8v8w1x5vvb5ljy5vwvhzkh0000gn/T/eas-build-local-nodejs/8bb8125d-ac16-4133-9f36-5054343383d4/build/node_modules/@babel/core/lib/gensync-utils/functional.js:22:27 [RUN_GRADLEW] at Generator.next (<anonymous>) [RUN_GRADLEW] at mergeChainOpts (/private/var/folders/3_/8m8v8w1x5vvb5ljy5vwvhzkh0000gn/T/eas-build-local-nodejs/8bb8125d-ac16-4133-9f36-5054343383d4/build/node_modules/@babel/core/lib/config/config-chain.js:349:34) [RUN_GRADLEW] at mergeChainOpts.next (<anonymous>) [RUN_GRADLEW] at chainWalker (/private/var/folders/3_/8m8v8w1x5vvb5ljy5vwvhzkh0000gn/T/eas-build-local-nodejs/8bb8125d-ac16-4133-9f36-5054343383d4/build/node_modules/@babel/core/lib/config/config-chain.js:316:14) [RUN_GRADLEW] at chainWalker.next (<anonymous>) [RUN_GRADLEW] at loadFileChain (/private/var/folders/3_/8m8v8w1x5vvb5ljy5vwvhzkh0000gn/T/eas-build-local-nodejs/8bb8125d-ac16-4133-9f36-5054343383d4/build/node_modules/@babel/core/lib/config/config-chain.js:191:24) [RUN_GRADLEW] at loadFileChain.next (<anonymous>) [RUN_GRADLEW] at mergeExtendsChain (/private/var/folders/3_/8m8v8w1x5vvb5ljy5vwvhzkh0000gn/T/eas-build-local-nodejs/8bb8125d-ac16-4133-9f36-5054343383d4/build/node_modules/@babel/core/lib/config/config-chain.js:328:28) [RUN_GRADLEW] at mergeExtendsChain.next (<anonymous>) [RUN_GRADLEW] at chainWalker (/private/var/folders/3_/8m8v8w1x5vvb5ljy5vwvhzkh0000gn/T/eas-build-local-nodejs/8bb8125d-ac16-4133-9f36-5054343383d4/build/node_modules/@babel/core/lib/config/config-chain.js:312:20) [RUN_GRADLEW] at chainWalker.next (<anonymous>) [RUN_GRADLEW] at buildRootChain (/private/var/folders/3_/8m8v8w1x5vvb5ljy5vwvhzkh0000gn/T/eas-build-local-nodejs/8bb8125d-ac16-4133-9f36-5054343383d4/build/node_modules/@babel/core/lib/config/config-chain.js:56:36) [RUN_GRADLEW] at buildRootChain.next (<anonymous>) [RUN_GRADLEW] at loadPrivatePartialConfig (/private/var/folders/3_/8m8v8w1x5vvb5ljy5vwvhzkh0000gn/T/eas-build-local-nodejs/8bb8125d-ac16-4133-9f36-5054343383d4/build/node_modules/@babel/core/lib/config/partial.js:72:62) [RUN_GRADLEW] at loadPrivatePartialConfig.next (<anonymous>) [RUN_GRADLEW] at loadFullConfig (/private/var/folders/3_/8m8v8w1x5vvb5ljy5vwvhzkh0000gn/T/eas-build-local-nodejs/8bb8125d-ac16-4133-9f36-5054343383d4/build/node_modules/@babel/core/lib/config/full.js:36:46) [RUN_GRADLEW] at loadFullConfig.next (<anonymous>) [RUN_GRADLEW] at transform (/private/var/folders/3_/8m8v8w1x5vvb5ljy5vwvhzkh0000gn/T/eas-build-local-nodejs/8bb8125d-ac16-4133-9f36-5054343383d4/build/node_modules/@babel/core/lib/transform.js:20:44) [RUN_GRADLEW] at transform.next (<anonymous>) [RUN_GRADLEW] at evaluateSync (/private/var/folders/3_/8m8v8w1x5vvb5ljy5vwvhzkh0000gn/T/eas-build-local-nodejs/8bb8125d-ac16-4133-9f36-5054343383d4/build/node_modules/gensync/index.js:251:28) [RUN_GRADLEW] at sync (/private/var/folders/3_/8m8v8w1x5vvb5ljy5vwvhzkh0000gn/T/eas-build-local-nodejs/8bb8125d-ac16-4133-9f36-5054343383d4/build/node_modules/gensync/index.js:89:14) [RUN_GRADLEW] at stopHiding - secret - don't use this - v1 (/private/var/folders/3_/8m8v8w1x5vvb5ljy5vwvhzkh0000gn/T/eas-build-local-nodejs/8bb8125d-ac16-4133-9f36-5054343383d4/build/node_modules/@babel/core/lib/errors/rewrite-stack-trace.js:47:12) [RUN_GRADLEW] at Object.transformSync (/private/var/folders/3_/8m8v8w1x5vvb5ljy5vwvhzkh0000gn/T/eas-build-local-nodejs/8bb8125d-ac16-4133-9f36-5054343383d4/build/node_modules/@babel/core/lib/transform.js:42:76) [RUN_GRADLEW] at parseWithBabel (/private/var/folders/3_/8m8v8w1x5vvb5ljy5vwvhzkh0000gn/T/eas-build-local-nodejs/8bb8125d-ac16-4133-9f36-5054343383d4/build/node_modules/@expo/metro-config/build/transformSync.js:57:18) [RUN_GRADLEW] at transformSync (/private/var/folders/3_/8m8v8w1x5vvb5ljy5vwvhzkh0000gn/T/eas-build-local-nodejs/8bb8125d-ac16-4133-9f36-5054343383d4/build/node_modules/@expo/metro-config/build/transformSync.js:46:12) [RUN_GRADLEW] at Object.transform (/private/var/folders/3_/8m8v8w1x5vvb5ljy5vwvhzkh0000gn/T/eas-build-local-nodejs/8bb8125d-ac16-4133-9f36-5054343383d4/build/node_modules/@expo/metro-config/build/babel-transformer.js:115:58) [RUN_GRADLEW] at transformJSWithBabel (/private/var/folders/3_/8m8v8w1x5vvb5ljy5vwvhzkh0000gn/T/eas-build-local-nodejs/8bb8125d-ac16-4133-9f36-5054343383d4/build/node_modules/@expo/metro-config/build/transform-worker/metro-transform-worker.js:341:47) [RUN_GRADLEW] at Object.transform (/private/var/folders/3_/8m8v8w1x5vvb5ljy5vwvhzkh0000gn/T/eas-build-local-nodejs/8bb8125d-ac16-4133-9f36-5054343383d4/build/node_modules/@expo/metro-config/build/transform-worker/metro-transform-worker.js:444:12) [RUN_GRADLEW] at Object.transform (/private/var/folders/3_/8m8v8w1x5vvb5ljy5vwvhzkh0000gn/T/eas-build-local-nodejs/8bb8125d-ac16-4133-9f36-5054343383d4/build/node_modules/@expo/metro-config/build/transform-worker/transform-worker.js:69:23) [RUN_GRADLEW] > Task :app:createBundleReleaseJsAndAssets FAILED [RUN_GRADLEW] FAILURE: [RUN_GRADLEW] Build failed with an exception. [RUN_GRADLEW] * What went wrong: [RUN_GRADLEW] Execution failed for task ':app:createBundleReleaseJsAndAssets'. [RUN_GRADLEW] > Process 'command 'node'' finished with non-zero exit value 1 [RUN_GRADLEW] * Try: [RUN_GRADLEW] > Run with --stacktrace option to get the stack trace. [RUN_GRADLEW] > Run with --info or --debug option to get more log output. [RUN_GRADLEW] > Run with --scan to get full insights. [RUN_GRADLEW] > Get more help at https://help.gradle.org. [RUN_GRADLEW] BUILD FAILED in 42s

My bable.config.js:
module.exports = function (api) { api.cache(true); return { presets: ["babel-preset-expo"], plugins: [ "react-native-reanimated/plugin", [ "module-resolver", { root: ["./"], extensions: [".js", ".jsx", ".ts", ".tsx"], alias: { "@assets": "./assets", "@components": "./components", "@contexts": "./contexts", "@locales": "./locales", "@screens": "screens", "@utils": "./utils", }, }, ], ], }; };

@jsdecena
Copy link

jsdecena commented Dec 8, 2024

I have this for a week now and cannot find how to resolve :((((

it is already installed but still failing just like your error. Mine is exactly the same.

[UPDATE]
I ended up removing this library. I just use the tsconfig.json and metro.config.js to resolve the paths.

// tsconfig
{
  "extends": "expo/tsconfig.base",
  "compilerOptions": {
    "baseUrl": ".",
    /* Absolute Imports */
    "paths": {
      "@/*": ["src/*"]
    }    
  }
}
// metro config
const { getDefaultConfig } = require('expo/metro-config');

const config = getDefaultConfig(__dirname);

config.resolver.alias = {
  '@': './src'
};

module.exports = config;

NOW IT IS BUILDING PROPERLY

@m8tec
Copy link
Author

m8tec commented Dec 8, 2024

I ended up removing this library as well and migrate completely to Typescript (which supports path aliases without plugin), which I planned to do anyway. Probably not the solution other people are here for, but at least we got it building again. 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants