Expo commands throwing “Error: Cannot find module 'minizlib'”

北战南征 提交于 2019-12-06 15:16:19

问题


Whenever I try to run such commands as expo init or expo start or even just expo, it responds with:

Error: Cannot find module 'minizlib'
Require stack:
- /usr/local/lib/node_modules/expo-cli/node_modules/tar/lib/pack.js
- /usr/local/lib/node_modules/expo-cli/node_modules/tar/lib/create.js
- /usr/local/lib/node_modules/expo-cli/node_modules/tar/index.js
- /usr/local/lib/node_modules/expo-cli/node_modules/@expo/xdl/build/Extract.js
- /usr/local/lib/node_modules/expo-cli/node_modules/@expo/xdl/build/Api.js
- /usr/local/lib/node_modules/expo-cli/node_modules/@expo/xdl/build/xdl.js
- /usr/local/lib/node_modules/expo-cli/build/exp.js
- /usr/local/lib/node_modules/expo-cli/bin/expo.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:625:15)
    at Function.Module._load (internal/modules/cjs/loader.js:527:27)
    at Module.require (internal/modules/cjs/loader.js:683:19)
    at require (internal/modules/cjs/helpers.js:16:16)
    at Object.<anonymous> (/usr/local/lib/node_modules/expo-cli/node_modules/tar/lib/pack.js:28:14)
    at Module._compile (internal/modules/cjs/loader.js:776:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
    at Module.load (internal/modules/cjs/loader.js:643:32)
    at Function.Module._load (internal/modules/cjs/loader.js:556:12)
    at Module.require (internal/modules/cjs/loader.js:683:19)

I have tried install and reinstalling minizlib, along with expo, expo-cli, npm, and node and nothing has worked. Any help would be appreciated.

OS: Ubuntu 18.04.2


回答1:


I had the same issue. I downgraded to version 10 of node using nvm install 10 (If you do not have NVM look into it here it is very useful) then reinstalled the expo-cli with npm install -g expo-cli. This ended up solving the issue for me.

Note: This downgrade is temporary if you want to make it your default version you have to run nvm alias default 10




回答2:


I had the same issue with "minizlib" not being found. None of the solutions posted on here or other threads regarding this issue solved it.

But, I figured it out. And here is what worked for me. Its pretty straight forward.

  • All the modules necessary for Expo to run should be located at /usr/local/lib/node_modules/expo-cli/node_modules/
  • So, go to your home directory and run npm install minizlib@2.1.0. This will put the module file in the home directory. (I say home directory so that the npm install doesnt clutter files into whichever directory you were previously working on)
  • Now, you need to copy+paste the module folder to whichever folder npm is looking for while running the expo command. In your case its /usr/local/lib/node_modules/expo-cli/node_modules/

This solved the problem for me. If it worked for anyone else, please validate it for me.




回答3:


install the library

npm install -g minizlib



回答4:


I had the same issue and I found the way to solve it in an external forum. thanks to @parkerroanm answer there.

Anyway, here is how I solved it (from the answer I found):

  1. I uninstalled expo-cli with this command: sudo npm uninstall -g expo-cli This is did not actually uninstall expo and nothing I could do would. So i deleted the folder with this command: sudo rm -r /usr/local/lib/node_modules/expo-cli
  2. Then reinstalled using yarn instead with: yarn global add expo-cli --save
  3. I updated the PATH in .bashrc to include export PATH="$(yarn global bin):$PATH" to the bottom of the file.

This fixed the issue for me.

It seems to all stem from a permissions error on installation for the sharp library.



来源:https://stackoverflow.com/questions/56998174/expo-commands-throwing-error-cannot-find-module-minizlib

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!