npx create-npx-module returns npm install exited with non-zero code: 127

I have an Expo app and I want to create an Expo module.

I use the following command:

npx create-expo-module my-module

This command returns the following error:

✖ Installing module dependencies
Error: npm install exited with non-zero code: 127
    at ChildProcess.completionListener (/root/.npm/_npx/62900f925a4b91dc/node_modules/@expo/spawn-async/build/spawnAsync.js:42:23)
    at Object.onceWrapper (node:events:627:26)
    at ChildProcess.emit (node:events:512:28)
    at maybeClose (node:internal/child_process:1098:16)
    at ChildProcess._handle.onexit (node:internal/child_process:304:5)
    ...
    at spawnAsync (/root/.npm/_npx/62900f925a4b91dc/node_modules/@expo/spawn-async/build/spawnAsync.js:7:23)
    at installDependencies (/root/.npm/_npx/62900f925a4b91dc/node_modules/create-expo-module/build/packageManager.js:9:37)
    at /root/.npm/_npx/62900f925a4b91dc/node_modules/create-expo-module/build/create-expo-module.js:64:56
    at newStep (/root/.npm/_npx/62900f925a4b91dc/node_modules/create-expo-module/build/utils.js:21:22)
    at Command.main (/root/.npm/_npx/62900f925a4b91dc/node_modules/create-expo-module/build/create-expo-module.js:63:31) {

My versions are:

node --version
v19.8.1

npm --version
9.5.1

yarn --version
3.5.5

Ubuntu 22.04 LTS

I have tried with Node 16.x and Node 18.x, resulting into the same error everytime. I have also tried with yarn create expo-module my-module as well.

This topic has already been reported here: create-expo-module fails in installing module dependencies stage · Issue #20018 · expo/expo · GitHub but I could not find any relevant answer for resolution (using Node exact version 16.0.0 creates other issues; anyway, I guess npx create-expo-module should work with latest versions of Node).

Am I missing something here ?

Hi @jean-lelievre

The last time I tried out create-expo-module, it worked like this:

  • It downloaded a template and unpacked it. This included code for an Android module and an iOS module and also an example app that made use of the module.
  • It then ran something (maybe pod install) in the iOS project.

The iOS part of this process did not work for me on Linux. Not sure if it’s possible to get that to work, but anyway the iOS project will need to be compiled with Xcode, so if you want the module to support iOS apps then you will unfortunately need a Mac.

I was trying it out and only wanted to create an Android module, so what I did was I got hold of the template and stripped out the iOS parts. Then I used the -s option to specify the path to the directory where I had the template. If I remember correctly I had some trouble with this when using a relative path to the template, but it was a while ago, so I can’t remember for sure.

It looks like you’re running this as root. That’s not generally a good idea.

By the way, there’s also a Discord channel for discussing Expo modules.

Thanks @wodin for your explanation.

Based on your explanation above regarding the create-expo-module steps, I have realized that despite the error I encounter, the folder with the module content is created correctly.

Then, I am able to execute the npm install or yarn install directly into the module folder, both commands succeed.

I am even able to find my module when using it in another local project (using npx expo-modules-autolinking search|resolve|verify) so I guess the installation works well in the end. npm run build works correctly as well in the module.

Honestly, I don’t know if the module is correctly created in the end, but at least I can run the commands above, so it seems to be okay.

I am now trying to use my module in my Expo app (importing it with import * as Settings from 'expo-settings'; and modifying the package.json file). Running the app with Expo Go still throws the error that the module cannot be found, but this is a different issue anyway, so I resolve this thread.

Thanks for your help!

These modules contain custom native code. Expo Go does not include this custom native code, so it cannot work.

What you can do instead is create a development build, which is basically like a custom version of Expo Go that includes all of the dependencies you have installed.

I have just tried, and it works correctly when I create a development build. As you say, I can now use native code from my Expo native module after importing it into the main app.

Thanks a lot @wodin for the insights !

1 Like

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.