react-nativefs-extra

Failling when installing fs-extra - react-native


~I'm creating a new app for android and when I command react-native run-android and this error comes up: error: bundling failed: Error: Unable to resolve module fs from C:\Users\luis.arnoni.fritzen\Documents\ReactNative\Hello\node_modules\expo-cli\build\exp.js: Module fs does not exist in the Haste module map

Reading some documentation, this seems to be an issue with the fs package. I tried to install the fs-extra package, but I got an error

   npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.9 
   (node_modules\fsevents):
   npm WARN optional SKIPPING OPTIONAL DEPENDENCY: Error: EPERM: operation 
   not permitted, rename 
   'C:\Users\luis.arnoni.fritzen\Documents\ReactNative
   \Hello\node_modules\.staging\fsevents-aa6bf958\node_modules\rc' -> 
   'C:\Users\luis.arnoni.fritzen\Documents
   \ReactNative\Hello\node_modules\.staging\rc-e2a21b3f'

   npm ERR! path C:\Users\luis.arnoni.fritzen\Documents\ReactNative\
   Hello\node_modules\fs-extra\lib\fs
   npm ERR! code EPERM
   npm ERR! errno -4048
   npm ERR! syscall unlink
   npm ERR! Error: EPERM: operation not permitted, unlink 
   'C:\Users\luis.arnoni.fritzen\Documents\
   ReactNative\Hello\node_modules\fs-extra\lib\fs'
   npm ERR!  { [Error: EPERM: operation not permitted, unlink 
   'C:\Users\luis.arnoni.fritzen\Documents\ReactNative\
   Hello\node_modules\fs-extra\lib\fs']
   npm ERR!   cause:
   npm ERR!    { Error: EPERM: operation not permitted, unlink 
   'C:\Users\luis.arnoni.fritzen\Documents\ReactNative\
   Hello\node_modules\fs-extra\lib\fs'
   npm ERR!      errno: -4048,
   npm ERR!      code: 'EPERM',
   npm ERR!      syscall: 'unlink',
   npm ERR!      path:
   npm ERR!       
   'C:\\Users\\luis.arnoni.fritzen\\Documents\\ReactNative\\
   Hello\\node_modules\\fs-extra\\lib\\fs' },
   npm ERR!   stack:
   npm ERR!    'Error: EPERM: operation not permitted, unlink 
   \'C:\\Users\\luis.arnoni.fritzen\\Documents\\
   ReactNative\\Hello\\node_modules\\fs-extra\\lib\\fs\'',
   npm ERR!   errno: -4048,
   npm ERR!   code: 'EPERM',
   npm ERR!   syscall: 'unlink',
   npm ERR!   path:
   npm ERR!    'C:\\Users\\luis.arnoni.fritzen\\Documents\\
   ReactNative\\Hello\\node_modules\\fs-extra\\lib\\fs',
   npm ERR!   parent: 'Hello' }
   npm ERR!
   npm ERR! The operation was rejected by your operating system.
   npm ERR! It's possible that the file was already in use (by a text 
   editor or antivirus),
   npm ERR! or that you lack permissions to access it.
   npm ERR!
   npm ERR! If you believe this might be a permissions issue, please 
   double-check the
   npm ERR! permissions of the file and its containing directories, or try 
   running
   npm ERR! the command again as root/Administrator (though this is not 
   recommended).

   npm ERR! A complete log of this run can be found in:
   npm ERR!     C:\Users\luis.arnoni.fritzen\AppData\Roaming\npm- 
   cache\_logs\2019-09-16T16_08_43_971Z-debug.log

Solution

  • react-native does not have a complete node environment. Not all node modules will work with react-native. You can consider using https://github.com/itinance/react-native-fs