React Native ~ Troubleshooting ~ Common Build Issues - rohit120582sharma/Documentation GitHub Wiki
If you get an error like Cannot find module 'npmlog', try installing npm directly:
curl -0 -L https://npmjs.org/install.sh | sudo sh
Fix this issue by creating rn-cli.config.js
file in root directory:
const Path = require('path');
module.exports = {
getProjectRoots: () => [
__dirname,
Path.join(__dirname, "./src")
]
};
Install below modules and create .babelrc
file in the root directory:
npm install --save-dev babel-preset-react-native babel-plugin-module-resolver
{
"presets": [
"react-native",
"babel-preset-react-native-stage-0/decorator-support"
],
"plugins": [
"transform-react-jsx-source",
[
"module-resolver",
{
"cwd": "babelrc",
"root": ["./src"],
"extensions": [
".js",
".ios.js",
".android.js"
],
"alias": {
"common": "./src/common",
"assets": "./src/assets",
"modules": "./src/modules",
"nav": "./src/nav",
"api.config": "./src/api.config"
}
}
]
]
}
Kill all running instances of the packager terminal window and reset the packager cache by restarting it with. Call each command in order:
react-native start -- --reset-cache
watchman watch-del-all
rm -rf /tmp/metro-bundler-cache-*
rm -rf /tmp/haste-map-react-native-packager-*
Still having issue, run npm install module
in project directory