Skip to content
This repository has been archived by the owner on Oct 7, 2021. It is now read-only.

Unrecognized command "set-icon" #6

Closed
blankey1337 opened this issue Sep 8, 2019 · 26 comments
Closed

Unrecognized command "set-icon" #6

blankey1337 opened this issue Sep 8, 2019 · 26 comments

Comments

@blankey1337
Copy link

blankey1337 commented Sep 8, 2019

After installing via npm, I am unable to run react-native set-icon, I get this error:

error Unrecognized command "set-icon".
info Run "react-native --help" to see a list of all available commands.

image

@HariharanIT
Copy link

After installing via npm, I am unable to run react-native set-icon, I get this error:

error Unrecognized command "set-icon".
info Run "react-native --help" to see a list of all available commands.

image

+1.. I am too getting the same

@yleflour
Copy link
Contributor

Hello, is @bam.tech/react-native-make listed as a dev dependency in your react-native project?
This plugin works as an extension of the local react-native-cli. Which means that to run it you have to be in the project folder.

To check if it works, set-icon should be listed when running react-native -h

@vieraleonel
Copy link

Same error here. In package.json:

"devDependencies": {
   "@bam.tech/react-native-make": "1.0.1-rc2",

React Native versión is 0.59.10

Hope this helps clarify

@yleflour
Copy link
Contributor

yleflour commented Sep 11, 2019

Can you copy/paste the output when running react-native --version?

Edit: For those encountering the issue I believe we are only compatible with up to date installs of react-native-cli. I'm waiting for confirmation but running npm install -g react-native-cli should fix the issue.

@vieraleonel
Copy link

react-native --version output is:

react-native-cli: 2.0.1
react-native: 0.59.10

@yleflour
Copy link
Contributor

Ok, same here, so wrong hypothesis.

Can you give me the output of react-native -h ?

@vieraleonel
Copy link

Here is the output:

# react-native -h
Usage: react-native [options] [command]

Options:
  --version                          Print CLI version
  --projectRoot [string]             Path to the root of the project
  --reactNativePath [string]         Path to React Native
  --verbose                          Increase logging verbosity
  -h, --help                         output usage information

Commands:
  start [options]                    starts the webserver
  run-ios [options]                  builds your app and starts it on iOS simulator
  run-android [options]              builds your app and starts it on a connected Android emulator or device
  new-library [options]              generates a native library bridge
  bundle [options]                   builds the javascript bundle for offline use
  ram-bundle [options]               builds javascript as a "Random Access Module" bundle for offline use
  eject [options]                    Re-create the iOS and Android folders and native code
  link [options] [packageName]       scope link command to certain platforms (comma-separated)
  unlink [options] <packageName>     unlink native dependency
  install [options] <packageName>    install and link native dependencies
  uninstall [options] <packageName>  uninstall and unlink native dependencies
  upgrade [options] [version]        Upgrade your app's template files to the specified or latest npm version using `rn-diff-purge` project. Only valid semver versions are allowed.
  log-android [options]              starts adb logcat
  log-ios [options]                  starts iOS device syslog tail
  dependencies [options]             lists dependencies
  info [options]                     Get relevant version info about OS, toolchain and libraries
  init [options]

Just in case it helps, my whole package.json:

{
  "name": "DPE",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "node node_modules/react-native/local-cli/cli.js start",
    "test": "jest",
    "clean": "rm -rf $TMPDIR/react-* && watchman watch-del-all && npm cache clean --force",
    "clean:android": "cd android/ && ./gradlew clean && cd .. && react-native run-android",
    "newclear": "rm -rf $TMPDIR/react-* && watchman watch-del-all && rm -rf ios/build && rm -rf node_modules/ && npm cache clean --force && npm i",
    "test:watch": "jest --watch",
    "updateSnapshot": "jest --updateSnapshot",
    "coverage": "jest --coverage && open coverage/lcov-report/index.html || xdg-open coverage/lcov-report/index.html",
    "android:build": "cd android && ./gradlew assembleRelease",
    "android:install": "cd android && ./gradlew assembleRelease && ./gradlew installRelease",
    "android:hockeyapp": "cd android && ./gradlew assembleRelease && puck -submit=auto app/build/outputs/apk/app-release.apk",
    "android:devices": "$ANDROID_HOME/platform-tools/adb devices",
    "android:logcat": "$ANDROID_HOME/platform-tools/adb logcat *:S ReactNative:V ReactNativeJS:V",
    "android:shake": "$ANDROID_HOME/platform-tools/adb devices | grep '\\t' | awk '{print $1}' | sed 's/\\s//g' | xargs -I {} $ANDROID_HOME/platform-tools/adb -s {} shell input keyevent 82",
    "storybook": "storybook start -p 7007",
    "lint": "standard --verbose | snazzy",
    "lintdiff": "git diff --name-only --cached --relative | grep '\\.js$' | xargs standard | snazzy",
    "fixcode": "standard --fix",
    "git-hook": "npm run lint -s && npm run test -s"
  },
  "dependencies": {
    "@react-native-community/async-storage": "1.6.1",
    "apisauce": "1.0.3",
    "format-json": "1.0.3",
    "i18n-js": "3.3.0",
    "identity-obj-proxy": "3.0.0",
    "lodash": "4.17.15",
    "prop-types": "15.7.2",
    "querystringify": "2.1.1",
    "ramda": "0.26.1",
    "react": "16.8.3",
    "react-native": "0.59.10",
    "react-native-config": "0.11.7",
    "react-native-device-info": "2.3.2",
    "react-native-fast-image": "6.1.1",
    "react-native-firebase": "5.5.6",
    "react-native-gesture-handler": "1.3.0",
    "react-native-localize": "1.1.4",
    "react-native-permissions": "1.2.0",
    "react-native-splash-screen": "3.2.0",
    "react-native-status-bar-height": "2.4.0",
    "react-native-vector-icons": "6.6.0",
    "react-native-webview": "5.8.2",
    "react-navigation": "3.11.1",
    "react-navigation-redux-helpers": "3.0.2",
    "react-redux": "6.0.1",
    "redux": "4.0.4",
    "redux-persist": "5.10.0",
    "redux-saga": "1.0.5",
    "reduxsauce": "1.1.0",
    "seamless-immutable": "7.1.4"
  },
  "devDependencies": {
    "@babel/core": "7.5.5",
    "@babel/runtime": "7.5.5",
    "@bam.tech/react-native-make": "1.0.1-rc2",
    "@storybook/addon-actions": "5.0.11",
    "@storybook/addon-links": "5.0.11",
    "@storybook/addon-storyshots": "4.1.18",
    "@storybook/addons": "4.1.18",
    "@storybook/channels": "4.1.18",
    "@storybook/react-native": "4.1.18",
    "babel-core": "6.26.3",
    "babel-eslint": "7.1.1",
    "babel-jest": "24.8.0",
    "babel-plugin-ignite-ignore-reactotron": "0.3.0",
    "babel-preset-env": "1.7.0",
    "babel-preset-react-native": "4.0.1",
    "enzyme": "3.10.0",
    "enzyme-adapter-react-16": "1.14.0",
    "ignite-andross": "4.1.0",
    "ignite-redux-persist": "2.0.0",
    "ignite-standard": "1.0.0",
    "jest": "24.8.0",
    "metro-react-native-babel-preset": "0.55.0",
    "mockery": "2.1.0",
    "react-devtools-core": "3.6.0",
    "react-dom": "16.7.0",
    "react-test-renderer": "16.8.3",
    "reactotron-react-native": "2.2.0",
    "reactotron-redux": "2.1.3",
    "reactotron-redux-saga": "3.0.0",
    "snazzy": "8.0.0",
    "standard": "10.0.2"
  },
  "jest": {
    "preset": "react-native",
    "testMatch": [
      "<rootDir>/Tests/**/*.js",
      "**/?(*.)(spec|test).js?(x)"
    ],
    "testPathIgnorePatterns": [
      "/node_modules/",
      "<rootDir>/Tests/Setup.js"
    ],
    "moduleNameMapper": {
      "^.+\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "identity-obj-proxy"
    },
    "transform": {
      "^.+\\.(js)$": "<rootDir>/node_modules/react-native/jest/preprocessor.js"
    },
    "setupFiles": [
      "<rootDir>/Tests/Setup"
    ]
  },
  "config": {},
  "standard": {
    "parser": "babel-eslint",
    "globals": [
      "describe",
      "test",
      "jest",
      "expect",
      "fetch",
      "navigator",
      "__DEV__",
      "XMLHttpRequest",
      "FormData",
      "React$Element"
    ]
  },
  "rnpm": {
    "assets": [
      "./assets/fonts"
    ]
  }
}

@yleflour
Copy link
Contributor

Thanks, also, which platform are you working on? Windows? Mac? Linux?

@vieraleonel
Copy link

Here goes with all other versions I think may help 😄 :
MacOS Mojave 10.14.5
node v10.15.0
npm 6.11.3
Shell zsh

@yleflour
Copy link
Contributor

yleflour commented Sep 12, 2019

I am completely unable to reproduce the issue.

If you are able to dig in, the way it works is that when running "react-native " in a RN project's folder, it loads up node_modules checking against the presence of a react-native.config.js file in the root folder. This file should export a valid config.

Can you replace your node_modules/@bam.tech/react-native-make/react-native.config.js file with the following and copy the output of react-native -h:

#!/usr/bin/env node
const { resolve } = require('path');
const { lstatSync } = require('fs');

/**
 * For faster development workflow, when npm linked
 * we want this library to be transpiled at runtime using the ts-node resolver
 */
try {
  const res = lstatSync(resolve('.', 'node_modules', '@bam.tech', 'react-native-make'));
  if (res.isSymbolicLink()) {
    console.warn('Detected linked install of react-native-make, compiling at runtime...');
    require('ts-node').register({ project: resolve(__dirname, `tsconfig.json`) });
    module.exports = require('./src/rn-plugin.config').rnPluginConfig;
  } else {
    const pluginConfig = require('./dist/rn-plugin.config.js').rnPluginConfig;
    console.warn(pluginConfig);
    module.exports = pluginConfig;
  }
} catch (err) {
  console.warn(err);
}

@samrodrigues
Copy link

samrodrigues commented Sep 12, 2019

I'm getting the same issue on macOS 10.14.6, after editing node_modules/@bam.tech/react-native-make/react-native.config.js with @yleflour 's proposed changes.

$ react-native -v
react-native-cli: 2.0.1
react-native: 0.59.8
$ node -v
v12.4.0
$ react-native -h
Commands:
  start [options]                    starts the webserver
  run-ios [options]                  builds your app and starts it on iOS simulator
  run-android [options]              builds your app and starts it on a connected Android emulator or device
  new-library [options]              generates a native library bridge
  bundle [options]                   builds the javascript bundle for offline use
  ram-bundle [options]               builds javascript as a "Random Access Module" bundle for offline use
  eject [options]                    Re-create the iOS and Android folders and native code
  link [options] [packageName]       scope link command to certain platforms (comma-separated)
  unlink [options] <packageName>     unlink native dependency
  install [options] <packageName>    install and link native dependencies
  uninstall [options] <packageName>  uninstall and unlink native dependencies
  upgrade [options] [version]        Upgrade your app's template files to the specified or latest npm version using `rn-diff-purge` project. Only valid semver versions are allowed.
  log-android [options]              starts adb logcat
  log-ios [options]                  starts iOS device syslog tail
  dependencies [options]             lists dependencies
  info [options]                     Get relevant version info about OS, toolchain and libraries
  init [options]

@vieraleonel
Copy link

Ok. First, just in case, this is the code before editing node_modules/@bam.tech/react-native-make/react-native.config.js:

#!/usr/bin/env node
const { resolve } = require('path');
const { lstatSync } = require('fs');

/**
 * For faster development workflow, when npm linked
 * we want this library to be transpiled at runtime using the ts-node resolver
 */
const res = lstatSync(resolve('.', 'node_modules', '@bam.tech', 'react-native-make'));
if (res.isSymbolicLink()) {
  console.warn('Detected linked install of react-native-make, compiling at runtime...');
  require('ts-node').register({ project: resolve(__dirname, `tsconfig.json`) });
  module.exports = require('./src/rn-plugin.config').rnPluginConfig;
} else {
  module.exports = require('./dist/rn-plugin.config.js').rnPluginConfig;
}

After editing:

$ react-native -h
Usage: react-native [options] [command]

Options:
  --version                          Print CLI version
  --projectRoot [string]             Path to the root of the project
  --reactNativePath [string]         Path to React Native
  --verbose                          Increase logging verbosity
  -h, --help                         output usage information

Commands:
  start [options]                    starts the webserver
  run-ios [options]                  builds your app and starts it on iOS simulator
  run-android [options]              builds your app and starts it on a connected Android emulator or device
  new-library [options]              generates a native library bridge
  bundle [options]                   builds the javascript bundle for offline use
  ram-bundle [options]               builds javascript as a "Random Access Module" bundle for offline use
  eject [options]                    Re-create the iOS and Android folders and native code
  link [options] [packageName]       scope link command to certain platforms (comma-separated)
  unlink [options] <packageName>     unlink native dependency
  install [options] <packageName>    install and link native dependencies
  uninstall [options] <packageName>  uninstall and unlink native dependencies
  upgrade [options] [version]        Upgrade your app's template files to the specified or latest npm version using `rn-diff-purge` project. Only valid semver versions are allowed.
  log-android [options]              starts adb logcat
  log-ios [options]                  starts iOS device syslog tail
  dependencies [options]             lists dependencies
  info [options]                     Get relevant version info about OS, toolchain and libraries
  init [options]

@yleflour
Copy link
Contributor

Thank you so much for taking the time to dig in.

It seems the plugin is not even loaded. This could be confirmed with a console.warn("loaded") at the top of the file. It might be an issue on react-native-cli's part but I don't understand where it could come from.

I found out about the node ./node_modules/react-native/cli.js config command but I expect react-native-make to not even be listed in the output on your environment...

I'm going to dig in how react-native-cli actually detects installed plugins

@yleflour
Copy link
Contributor

Okay, I was able to reproduce the bug by starting a project with react-native@0.59.10

The CLI used seems to be the one installed locally instead of the global one which is incompatible with the configuration in react-native-make.

I will be working on a workaround

@yleflour
Copy link
Contributor

Just added a compat layer for react-native-cli@1.x and published it in 1.0.2.
A yarn add -D @bam.tech/react-native-make should work ;)

I will be waiting for confirmation to close the issue

@samrodrigues
Copy link

It works after the update, great job!

@vieraleonel
Copy link

vieraleonel commented Sep 12, 2019

Working here too! 👏 🥂

@yleflour
Copy link
Contributor

Guess this is officially closed 💥

@efstathiosntonas
Copy link

efstathiosntonas commented Sep 19, 2019

Bumped in the same issue using: @yleflour

react-native-cli: 2.0.1
react-native: 0.61.0-rc.3
react-native-make 1.0.2 
"devDependencies": {
    "@babel/core": "^7.6.0",
    "@babel/runtime": "^7.6.0",
    "@bam.tech/react-native-make": "^1.0.2",
...

using macOS 10.14.6, npm 6.11.3, node 10.16.3

@rogerzklotz
Copy link

Also running into the same issue as @efstathiosntonas

react-native-cli: 2.0.1
react-native: 0.60.5
react-native-make 1.0.2 
"devDependencies": {
    "@babel/core": "7.6.0",
    "@babel/runtime": "7.6.0",
    "@bam.tech/react-native-make": "1.0.2",
...

Any thoughts?

@yleflour yleflour reopened this Sep 23, 2019
@yleflour
Copy link
Contributor

Hello, @efstathiosntonas , I am unable to reproduce the issue:

What I did:

react-native init TestProject --version 0.61.0-rc.3
cd TestProject
yarn add -D @bam.tech/react-native-make
react-native -h
# Check: The  "make" commands are displayed

Are you able to reproduce it on another project?

@efstathiosntonas
Copy link

efstathiosntonas commented Sep 23, 2019

I ll check again first thing tomorrow morning and I will post back.

I’m guessing the issue occurred because i jumped from 0.60.5 to rc3 via the upgrade tool and some packages might be messed up, I’ll delete node_modules and try again.

@NicoCevallos
Copy link

Hey, I used

react-native init TestProject
cd TestProject
npm i -D @bam.tech/react-native-make

and when I run react-native -h I don't see any new option.
I'm using:

react-native-cli: 2.0.1
react-native: 0.61.0 (also tried with 0.61.0-rc.3)
@bam.tech/react-native-make: 1.0.2

Is there a way to run it out of react-native-cli?

@NicoCevallos
Copy link

OK, I suspected that, but thought that could not be the problem, but yes. I used yarn instead npm and then I see the available plugins with -h.
I hope it helps to find the solution soon.

@yleflour
Copy link
Contributor

Just published a fix in 1.0.3

With Yarn, node_modules folder architecture is flat whereas with NPM it is nested

@yleflour yleflour reopened this Sep 25, 2019
@efstathiosntonas
Copy link

Thanks @yleflour for fixing it so quick. Sorry for not posting back.

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

8 participants