Skip to content
This repository has been archived by the owner on Dec 15, 2020. It is now read-only.

Cannot find module 'metro/src/blacklist' #721

Closed
yukinoda opened this issue Jul 25, 2019 · 8 comments
Closed

Cannot find module 'metro/src/blacklist' #721

yukinoda opened this issue Jul 25, 2019 · 8 comments

Comments

@yukinoda
Copy link

React 360 Command Line Interface
Version 1.1.0

npm -v
6.9.0

The following error appears when doing "npm start"

open browser at http://localhost:8081/index.html


Starting React Native Packager...
error Cannot find module 'metro/src/blacklist'. Run CLI with --verbose flag for more details.
Error: Cannot find module 'metro/src/blacklist'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:613:15)
    at Function.Module._load (internal/modules/cjs/loader.js:539:25)
    at Module.require (internal/modules/cjs/loader.js:667:17)
    at require (internal/modules/cjs/helpers.js:20:18)
    at Object.<anonymous> (/Users/yuki-noda/Documents/GitHub/myGit/react-360-test/rn-cli.config.js:4:17)
    at Module._compile (internal/modules/cjs/loader.js:738:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:749:10)
    at Module.load (internal/modules/cjs/loader.js:630:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:570:12)
    at Function.Module._load (internal/modules/cjs/loader.js:562:3)
An error occurred during the packager process. Exited with code 1.
Look at the packager output above to see what went wrong.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! react_360_test@0.0.1 start: `node node_modules/react-360/scripts/packager.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the react_360_test@0.0.1 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
@chidinmae
Copy link

Based on this comment facebook/react-native#20799 (comment) I updated line 4 in rn-cli.config.js from var blacklist = require('metro/src/blacklist'); to var blacklist = require('metro-config/src/defaults/blacklist');

@yukinoda
Copy link
Author

yukinoda commented Jul 29, 2019

Thank you for the comment @chidinmae .

I tried the same solution from facebook/react-native/issues/21093 but the following warning appears in my terminal window

Starting React Native Packager...
● Validation Warning:

  Unknown option "getProjectRoots" with value getProjectRoots() {
    return getRoots();
  } was found.
  This is probably a typing mistake. Fixing it will remove this message.

● Validation Warning:

  Unknown option "getBlacklistRE" with value getBlacklistRE() {
    return blacklist([
    ]);
  } was found.
  This is probably a typing mistake. Fixing it will remove this message.

● Validation Warning:

  Unknown option "getAssetExts" with value getAssetExts() {
    return ['obj', 'mtl'];
  } was found.
  This is probably a typing mistake. Fixing it will remove this message.

● Validation Warning:

  Unknown option "getPlatforms" with value getPlatforms() {
    return ['vr'];
  } was found.
  This is probably a typing mistake. Fixing it will remove this message.

● Validation Warning:

  Unknown option "getProvidesModuleNodeModules" with value getProvidesModuleNodeModules() {
    return ['react-native', 'react-360'];
  } was found.
  This is probably a typing mistake. Fixing it will remove this message.

and shows only a blank page in my browser with the following errors in the console.

index.html:10 GET http://localhost:8081/client.bundle?platform=vr 500 (Internal Server Error)
index.html:13 Uncaught ReferenceError: React360 is not defined
    at index.html:13
(anonymous) @ index.html:13
favicon.ico:1 GET http://localhost:8081/favicon.ico 404 (Not Found)

@chidinmae
Copy link

Not sure about this one! The error I got after fixing the rn-cli config was related to watchman and fixed by running brew install watchman. Maybe try npm install metro for this?

@suhdonghwi
Copy link

Not running npm audit fix helped me.

@mcruz20
Copy link

mcruz20 commented Jan 14, 2020

I found a solution. If you're using react native >= 0.59 change your file name rn-cli.config.js to metro.config.js.

Then change your code, for example:

const blacklist = require('metro-config/src/defaults/blacklist');

module.exports = {
    getBlacklistRE() {
        return blacklist([
            /scripts\/.*/,
        ]);
    },
};

To:

const blacklist = require('metro-config/src/defaults/blacklist');

module.exports = {
    resolver: {
        blacklistRE: blacklist([/scripts\/.*/])
    },
};

Following the documentation from metro.

@Herbertbhs02
Copy link

Having the same issue:
error Cannot find module 'metro/src/blacklist'
Require stack:

  • C:\Users\hsev\Documents\HouseTour\rn-cli.config.js
  • C:\Users\hsev\Documents\HouseTour\node_modules\import-fresh\index.js
  • C:\Users\hsev\Documents\HouseTour\node_modules\cosmiconfig\dist\loaders.js
  • C:\Users\hsev\Documents\HouseTour\node_modules\cosmiconfig\dist\createExplorer.js
  • C:\Users\hsev\Documents\HouseTour\node_modules\cosmiconfig\dist\index.js
  • C:\Users\hsev\Documents\HouseTour\node_modules\react-native\node_modules@react-native-community\cli\build\tools\config\readConfigFromDisk.js
  • C:\Users\hsev\Documents\HouseTour\node_modules\react-native\node_modules@react-native-community\cli\build\tools\config\index.js
  • C:\Users\hsev\Documents\HouseTour\node_modules\react-native\node_modules@react-native-community\cli\build\commands\install\install.js
  • C:\Users\hsev\Documents\HouseTour\node_modules\react-native\node_modules@react-native-community\cli\build\commands\index.js
  • C:\Users\hsev\Documents\HouseTour\node_modules\react-native\node_modules@react-native-community\cli\build\index.js- C:\Users\hsev\Documents\HouseTour\node_modules\react-native\local-cli\cli.js. Run CLI with --verbose flag for more
    details.

@solchef
Copy link

solchef commented Jul 5, 2020

var blacklist = require('metro-config/src/defaults/blacklist');

THis resolved my issue too

@yukinoda
Copy link
Author

yukinoda commented Nov 5, 2020

Will close this issue since it is solved

@yukinoda yukinoda closed this as completed Nov 5, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants