How to set React_Editor to PhpStorm so that when you click on the error it jumps to the code?

Viewed 854

I'm using PhpStorm in Mac to code and i want to debug my errors. I have a message in my terminal to set the editor for React Native tools.

    PRO TIP 
  When you see Red Box with stack trace, you can click any 
  stack frame to jump to the source file. The packager will launch your 
  editor of choice. It will first look at REACT_EDITOR environment 
  variable, then at EDITOR.
  To set it up, you can add something like 
  export REACT_EDITOR=atom to your ~/.bashrc or ~/.zshrc depending on 
  which shell you use.

I've added these lines to ~/.bashrc but nothing happened when i click on the error :

export PATH=$PATH:/usr/local/bin/pstorm
export REACT_EDITOR=pstorm

How can i set correctly REACT_EDITOR to PhpStorm so that when i click on the error it jumps to my code?

2 Answers

For mac os you need to add to ~/.bashrc or .zprofile:

Add export REACT_EDITOR="webstorm" or pstorm

Don't forget to close all of your terminal windows and restart the react-native packager before you try it.

Create a shortcut to open WebStorm:

  1. Open WebStorm
  2. Press ⇧ twice to open the search window
  3. Type “Create Command Line Launcher…” and press Enter
  4. Click OK enter image description here

That's it.

/usr/local/bin should be in the PATH environment variable by default. You should be able to run webstorm from anywhere in the shell. Run webstorm /usr/local/bin/webstorm to test the command.

You can find a code which opens editors here or in your project node_modules/@react-native-community/cli-tools/build/launchEditor.js

I solved this problem by creating symlink.

sudo ln -s /Applications/WebStorm.app/Contents/MacOS/webstorm /usr/local/bin/webstorm
Related