Reproduce:
Atom: 1.16.0 x64
Electron: 1.3.13
OS: Mac OS X 10.11.6
Thrown From: prettier-atom package 0.30.0
Uncaught Error: ENOENT: no such file or directory, open 'package.json'
At fs.js:640
Error: ENOENT: no such file or directory, open 'package.json'
at Error (native)
at Object.fs.openSync (fs.js:640:18)
at Object.module.(anonymous function) [as openSync] (ELECTRON_ASAR.js:168:20)
at Object.fs.readFileSync (fs.js:508:33)
at Object.fs.readFileSync (ELECTRON_ASAR.js:501:29)
at /packages/prettier-atom/node_modules/load-json-file/index.js:11:38)
at Function.module.exports.sync (/packages/prettier-atom/node_modules/read-pkg/index.js:40:25)
at getDebugInfo (/packages/prettier-atom/dist/helpers.js:200:34)
at displayDebugInfo (/packages/prettier-atom/dist/displayDebugInfo.js:7:14)
at /packages/prettier-atom/dist/main.js:57:3)
at CommandRegistry.module.exports.CommandRegistry.handleCommandEvent (/app.asar/src/command-registry.js:259:29)
at /app.asar/src/command-registry.js:3:59
at Object.didConfirmSelection (/app.asar/node_modules/command-palette/lib/command-palette-view.js:106:29)
at SelectListView.confirmSelection (/app.asar/node_modules/atom-select-list/src/select-list-view.js:292:20)
at /app.asar/node_modules/atom-select-list/src/select-list-view.js:64:14)
at CommandRegistry.module.exports.CommandRegistry.handleCommandEvent (/app.asar/src/command-registry.js:259:29)
at /app.asar/src/command-registry.js:3:59
at KeymapManager.module.exports.KeymapManager.dispatchCommandEvent (/app.asar/node_modules/atom-keymap/lib/keymap-manager.js:599:16)
at KeymapManager.module.exports.KeymapManager.handleKeyboardEvent (/app.asar/node_modules/atom-keymap/lib/keymap-manager.js:390:22)
at WindowEventHandler.module.exports.WindowEventHandler.handleDocumentKeyEvent (/app.asar/src/window-event-handler.js:106:36)
at /app.asar/src/window-event-handler.js:3:59)
-1:18.7.0 core:save (input.hidden-input)
2x -0:58.1.0 core:move-up (input.hidden-input)
-0:57.7.0 core:move-left (input.hidden-input)
-0:53.5.0 editor:select-to-end-of-line (input.hidden-input)
-0:53.5.0 core:select-left (input.hidden-input)
-0:53.1.0 editor:select-to-beginning-of-word (input.hidden-input)
2x -0:52.7.0 core:select-left (input.hidden-input)
-0:52.2.0 core:copy (input.hidden-input)
-0:52 core:move-right (input.hidden-input)
-0:51 core:paste (input.hidden-input)
-0:50.9.0 core:save (input.hidden-input)
-0:37.7.0 core:cut (input.hidden-input)
-0:37.6.0 core:save (input.hidden-input)
-0:10.7.0 command-palette:toggle (input.hidden-input)
-0:09.6.0 core:confirm (input.hidden-input)
-0:09.6.0 prettier:debug (input.hidden-input)
activate-power-mode 1.4.0
atom-autocomplete-php 0.22.2
atom-beautify 0.29.23
busy-signal 1.4.1
color-picker 2.2.5
file-icons 2.1.4
go-debug 1.3.1
go-plus 5.5.1
go-signature-statusbar 1.2.0
hyperclick 0.0.40
ide-purescript 0.17.2
intentions 1.1.2
language-docker 1.1.7
language-elm 1.5.0
language-javascript-jsx 0.3.7
language-protobuf 0.7.1
language-purescript 0.8.2
language-rust 0.4.10
linter 2.1.4
linter-eslint 8.1.7
linter-flow 5.6.0
linter-php 1.3.2
linter-rust 0.8.0
linter-ui-default 1.2.3
nuclide 0.223.0
php-twig 4.0.0
pigments 0.39.1
prettier-atom 0.30.0
racer 0.20.0
react 0.16.2
vim-mode-plus 0.91.0
Thanks for reporting this, this is a bug. We got around this by not formatting on save, but if the user manually invokes, then we are trying to find a package.json from a non-existent filepath. Will fix.
@robwise Did you reproduce the issue? I can't so I'm wondering if it's OS-specific (I'm on Windows).
@tbillington When you say "unsaved", do you mean it's a newly created file or a file that already existed but has unsaved changes?
@darahak the latter, existing file that I've edited and have yet to save.
Hmm, in that case I'm not sure, as this is the normal use case and it seems to be working otherwise. Have you tried uninstalling and re-installing the package?
I tried uninstalling and reinstalling. When I run format instead of debug, I get this:
prettier-atom failed!
Validation Error:
Option "trailingComma" must be of type:
boolean
but instead received:
string
Example:
{
"trailingComma": false
}
I experience the same error when run prettier debug from atom (package.json is in the project repo):
**Atom**: 1.16.0 x64
**Electron**: 1.3.13
**OS**: Mac OS X 10.12.4
**Thrown From**: [prettier-atom](https://github.com/prettier/prettier-atom) package 0.30.0
### Stack Trace
Uncaught Error: ENOENT: no such file or directory, open 'package.json'
At fs.js:640
Error: ENOENT: no such file or directory, open 'package.json'
at Error (native)
at Object.fs.openSync (fs.js:640:18)
at Object.module.(anonymous function) [as openSync] (ELECTRON_ASAR.js:168:20)
at Object.fs.readFileSync (fs.js:508:33)
at Object.fs.readFileSync (ELECTRON_ASAR.js:501:29)
at /packages/prettier-atom/node_modules/load-json-file/index.js:11:38)
at Function.module.exports.sync (/packages/prettier-atom/node_modules/read-pkg/index.js:40:25)
at getDebugInfo (/packages/prettier-atom/dist/helpers.js:200:34)
at displayDebugInfo (/packages/prettier-atom/dist/displayDebugInfo.js:7:14)
at /packages/prettier-atom/dist/main.js:57:3)
at CommandRegistry.module.exports.CommandRegistry.handleCommandEvent (/app.asar/src/command-registry.js:259:29)
at /app.asar/src/command-registry.js:3:59
at Object.didConfirmSelection (/app.asar/node_modules/command-palette/lib/command-palette-view.js:106:29)
at SelectListView.confirmSelection (/app.asar/node_modules/atom-select-list/src/select-list-view.js:292:20)
at /app.asar/node_modules/atom-select-list/src/select-list-view.js:64:14)
at CommandRegistry.module.exports.CommandRegistry.handleCommandEvent (/app.asar/src/command-registry.js:259:29)
at /app.asar/src/command-registry.js:3:59
at KeymapManager.module.exports.KeymapManager.dispatchCommandEvent (/app.asar/node_modules/atom-keymap/lib/keymap-manager.js:599:16)
at KeymapManager.module.exports.KeymapManager.handleKeyboardEvent (/app.asar/node_modules/atom-keymap/lib/keymap-manager.js:390:22)
at WindowEventHandler.module.exports.WindowEventHandler.handleDocumentKeyEvent (/app.asar/src/window-event-handler.js:106:36)
at /app.asar/src/window-event-handler.js:3:59)
### Commands
-5:34.2.0 editor:toggle-line-comments (input.hidden-input)
-5:33.8.0 core:move-down (input.hidden-input)
-5:33.5.0 editor:toggle-line-comments (input.hidden-input)
-5:30.2.0 core:save (input.hidden-input)
-5:25.3.0 core:copy (input.hidden-input)
-1:54.3.0 command-palette:toggle (input.hidden-input)
-1:50.3.0 core:confirm (input.hidden-input)
-1:50.3.0 prettier:debug (input.hidden-input)
2x -1:36.7.0 core:copy (atom-notification.fatal.icon.icon-bug.native-key-bindings.has-detail.has-close.has-stack)
### Non-Core Packages
atom-beautify 0.29.24
atom-html-preview 0.1.22
atom-terminal 0.8.0
autoclose-html 0.23.0
ava 0.10.0
busy-signal 1.4.1
docblockr 0.9.4
editorconfig 2.2.2
elm-format 2.1.0
gist-it 0.9.2
html-to-elm 0.2.0
hyperclick 0.0.40
intentions 1.1.2
js-hyperclick 1.11.0
language-babel 2.61.0
language-elm 1.5.0
language-graphql-lb 0.3.1
linter 2.1.4
linter-elm-make 0.23.2
linter-eslint 8.1.7
linter-flow 5.6.0
linter-stylelint 3.10.0
linter-ui-default 1.2.4
markdown-writer 2.6.5
monokai-shade 0.3.5
pigments 0.39.1
prettier-atom 0.30.0
pretty-json 1.6.3
project-manager 3.3.4
sort-lines 0.14.0
Sublime-Style-Column-Selection 1.7.4
tabs-to-spaces 1.0.3
todo-show 1.11.0
Zen 0.16.4
```
Maybe the current directory is not set to prettier-atom's package and read-pkg struggles to find package.json.
I'll investigate ASAP.
@darahak just a heads-up, I'm in the process of a big refactoring of codebase's file structure, I should be done sometime this weekend
@tbillington @dacz The fix will probably be included in the next update (like 0.31.1 or 0.32.0).
I fixed what looked like the origin of the bug, but I never reproduced the issue.
Please retry when you get the update and tell us if it's resolved.
@robwise Didn't you publish 0.31.0 a few hours ago?
This change is very recent; I don't think it's included in it.
Yeah I didn't realize you had merged a PR, so I assumed you were talking about some commit from a while ago
I updated prettier-atom and still having the issue.
Just want to chime in and say I have this issue as well. Also,
Validation Error:
Option "tabWidth" must be of type:
number
but instead received:
string
Example:
{
"tabWidth": 2
}
@dacz The fix has not been released yet actually.
@joarwilk It looks like the same problem as https://github.com/prettier/prettier-atom/issues/72. There could be some helpful suggestions for you there.
Confirming that the latest update has fixed the issue for me. Both the format and debug commands now work :) thanks!
Excellent news!
Most helpful comment
Confirming that the latest update has fixed the issue for me. Both the format and debug commands now work :) thanks!