Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expected a Target error #43

Open
TmasLove opened this issue May 1, 2017 · 17 comments
Open

Expected a Target error #43

TmasLove opened this issue May 1, 2017 · 17 comments
Labels

Comments

@TmasLove
Copy link

TmasLove commented May 1, 2017

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)

@magbicaleman
Copy link
Owner

Thank you for reporting this @TmasLove

@TmasLove
Copy link
Author

TmasLove commented May 1, 2017

Yes sir, no problem-o.

Any idea on how to get around this?

@seasidesun
Copy link

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

@magbicaleman
Copy link
Owner

magbicaleman commented May 26, 2017

@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
Copy link
Owner

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

@brettgoss
Copy link

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.

@TmasLove
Copy link
Author

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

@jwolfe890
Copy link

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

@ericmarrone
Copy link

ericmarrone commented Oct 25, 2017

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.

@pakastin
Copy link

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

@fernandohg97
Copy link

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.

@matippetts
Copy link

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

@MicFin
Copy link

MicFin commented Sep 17, 2019

This issue still persists for Atom users in Sept 2019

@MohammadA98
Copy link

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

@matippetts
Copy link

matippetts commented Apr 1, 2020

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. 😨

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.

@AnnaFBD
Copy link

AnnaFBD commented Sep 12, 2020

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.

@GeorgeCiesinski
Copy link

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests