open-in-browser icon indicating copy to clipboard operation
open-in-browser copied to clipboard

Expected a Target error

Open TmasLove opened this issue 8 years ago • 17 comments

Error: Expected a target Error: Expected a target at module.exports (/Users/Tommy/.atom/packages/open-in-browser/node_modules/opn/index.js:9:25) at Object.open (/Users/Tommy/.atom/packages/open-in-browser/lib/open-in-browser.coffee:22:5) at Object.openEditor (/Users/Tommy/.atom/packages/open-in-browser/lib/open-in-browser.coffee:16:6) at CommandRegistry.module.exports.CommandRegistry.handleCommandEvent (/Applications/Atom.app/Contents/Resources/app.asar/src/command-registry.js:259:29) at CommandRegistry.handleCommandEvent (/Applications/Atom.app/Contents/Resources/app.asar/src/command-registry.js:3:59) at CommandRegistry.module.exports.CommandRegistry.dispatch (/Applications/Atom.app/Contents/Resources/app.asar/src/command-registry.js:160:19) at AtomEnvironment.module.exports.AtomEnvironment.dispatchApplicationMenuCommand (/Applications/Atom.app/Contents/Resources/app.asar/src/atom-environment.js:1179:28) at EventEmitter.outerCallback (/Applications/Atom.app/Contents/Resources/app.asar/src/application-delegate.js:312:25) at emitThree (events.js:116:13) at EventEmitter.emit (events.js:194:7)

TmasLove avatar May 01 '17 15:05 TmasLove

Thank you for reporting this @TmasLove

magbicaleman avatar May 01 '17 18:05 magbicaleman

Yes sir, no problem-o.

Any idea on how to get around this?

TmasLove avatar May 01 '17 18:05 TmasLove

Macos meet the same error, when the file name likes: scroll.html, vue.html, position.html...

seasidesun avatar May 25 '17 02:05 seasidesun

@TmasLove I was able to reproduce the error, on an unsaved initial file (untitled). I haven't been able to reproduce it, on an existing file.

What's happening under the hood is that opn npm package is not getting a file path, so it's triggering that error.

magbicaleman avatar May 26 '17 04:05 magbicaleman

Pushed out a new version, let me know if it fixed:

magbicaleman avatar May 26 '17 05:05 magbicaleman

I'm still getting this error on 0.5.2 when trying to open most .html files. Also seems to be happening with some other file extensions such as .json and .css with the same error message.

Let me know if there's any more info I can get for you to be able to track it down.

brettgoss avatar May 31 '17 09:05 brettgoss

I haven't been able to try it out but if @brettgoss is getting errors, I probably will as well

TmasLove avatar May 31 '17 13:05 TmasLove

I'm getting it too on the most basic html project.

jwolfe890 avatar Oct 06 '17 05:10 jwolfe890

I am also getting this error running OS X High Sierra.

EDIT: I uninstalled the package and tried installing by command line in Terminal and that worked.

ericmarrone avatar Oct 25 '17 02:10 ericmarrone

I've also had issues this for quite a long time now. Still persists.

pakastin avatar Nov 20 '17 15:11 pakastin

I had the same issue and I didn't notice that I had many packages outdated. I just updated all the packages and the issue was fixed.

fernandohg97 avatar May 21 '18 19:05 fernandohg97

I have had this and many similar problems when opening files located in directories other than Atom's working directory. As a work-around:

  • To open the file in a new instance of Atom, do cd $PARENT_OF_FILE_TO_EDIT; atom .
  • To open the file in a running instance, do cd $PARENT_OF_FILE_TO_EDIT; atom $FILE_TO_EDIT

matippetts avatar Oct 05 '18 20:10 matippetts

This issue still persists for Atom users in Sept 2019

MicFin avatar Sep 17 '19 15:09 MicFin

This is still going on in March 2020, Catalina OS.

MohammadA98 avatar Mar 20 '20 02:03 MohammadA98

I submitted a PR for this a year and a half ago. Nobody cared. The last commit was a year before that. The project contributors seem to have lost interest in maintaining the package. I thought about hunting them down and badgering them, but I know what happens to badgers. :fearful:

It's easy enough to fork this repo and fix the problem yourself (yay FOSS!). Just install your forked version (with a higher release number!) over the original APM.

matippetts avatar Apr 01 '20 11:04 matippetts

I know this error is old... but I found this page when I was trying to figure out what was going on. Eventually, I noticed that this error is only caused when you right click outside of the file name itself - so it's failing to pick up the filename you want to open in a browser. If you make sure you click on the filename itself and then on 'open in browser' it seems to solve the problem.

AnnaFBD avatar Sep 12 '20 15:09 AnnaFBD

This bug is still happening in 2022.

OS: macOS Monterey 12.3 open-in-browser version: 0.5.2

Bug report:

Error: Expected a target

Error: Expected a `target`
    at module.exports (/Users/georgeciesinski/.atom/packages/open-in-browser/node_modules/opn/index.js:9:25)
    at Object.open (/Users/georgeciesinski/.atom/packages/open-in-browser/lib/open-in-browser.coffee:24:5)
    at Object.openTreeView (/Users/georgeciesinski/.atom/packages/open-in-browser/lib/open-in-browser.coffee:21:6)
    at CommandRegistry.handleCommandEvent (/Applications/Atom.app/Contents/Resources/app/static/<embedded>:11:352694)
    at CommandRegistry.dispatch (/Applications/Atom.app/Contents/Resources/app/static/<embedded>:11:351169)
    at AtomEnvironment.dispatchContextMenuCommand (/Applications/Atom.app/Contents/Resources/app/static/<embedded>:1:786983)
    at EventEmitter.t (/Applications/Atom.app/Contents/Resources/app/static/<embedded>:1:795037)
    at EventEmitter.emit (events.js:223:5)
    at Object.onMessage (electron/js2c/renderer_init.js:115:818)

GeorgeCiesinski avatar Apr 03 '22 20:04 GeorgeCiesinski