请问atom 如何修改asar文件里的内容。

我用atom修改了 asar 里的文件后无法保存。@jysperm

[Enter steps to reproduce below:]

Atom Version: 1.0.19
System: Mac OS X 10.10.5
Thrown From: Atom Core

Stack Trace

Uncaught Error: ENOENT, not found in /Users/Cat/Desktop/windowspixate/pixate/app-1.7.0/resources/app.asar

At /Applications/Atom.app/Contents/Resources/app.asar/src/pane.js:809

Error: ENOENT,  not found in /Users/Cat/Desktop/windowspixate/pixate/app-1.7.0/resources/app.asar
    at notFoundError (ATOM_SHELL_ASAR.js:104:13)
    at Object.module.(anonymous function) [as openSync] (ATOM_SHELL_ASAR.js:145:9)
    at Object.fs.writeFileSync (fs.js:1165:15)
    at Object.fsPlus.writeFileSync (/Applications/Atom.app/Contents/Resources/app.asar/node_modules/fs-plus/lib/fs-plus.js:279:17)
    at File.module.exports.File.writeFileSync (/Applications/Atom.app/Contents/Resources/app.asar/node_modules/text-buffer/node_modules/pathwatcher/lib/file.js:277:19)
    at File.module.exports.File.writeFileWithPrivilegeEscalationSync (/Applications/Atom.app/Contents/Resources/app.asar/node_modules/text-buffer/node_modules/pathwatcher/lib/file.js:377:21)
    at File.module.exports.File.writeSync (/Applications/Atom.app/Contents/Resources/app.asar/node_modules/text-buffer/node_modules/pathwatcher/lib/file.js:350:12)
    at TextBuffer.module.exports.TextBuffer.saveAs (/Applications/Atom.app/Contents/Resources/app.asar/node_modules/text-buffer/lib/text-buffer.js:1023:19)
    at TextBuffer.module.exports.TextBuffer.save (/Applications/Atom.app/Contents/Resources/app.asar/node_modules/text-buffer/lib/text-buffer.js:1004:19)
    at TextEditor.module.exports.TextEditor.save (/Applications/Atom.app/Contents/Resources/app.asar/src/text-editor.js:584:26)

Commands

  4x -2:40.5.0 core:move-up (atom-text-editor.editor.is-focused)
 17x -2:31.4.0 core:undo (atom-text-editor.editor.is-focused)
  7x -2:22.5.0 core:redo (atom-text-editor.editor.is-focused)
 49x -2:19.4.0 core:undo (atom-text-editor.editor.is-focused)
  3x -2:02.9.0 core:save (atom-text-editor.editor.is-focused)
  3x -0:26 core:backspace (atom-text-editor.editor.is-focused)
  4x -0:10.1.0 core:save (atom-text-editor.editor.is-focused)

Config

{}

Installed Packages

# User
No installed packages

# Dev
No dev packages
1赞

The archives can not be modified so all Node APIs that can modify files will not work with asar archives.

asar 在设计上是一种为了快速读取小文件的打包机制,打包后的 asar 在设计上是只读的,Atom(Electron) 也没有提供写入 asar 的 API.

如果你一定要修改 asar 的话,需要将它解包,然后重新打包。

没看懂怎么解包的,打包知道怎么回事了。@jyspermj 有解包的方法教程吗?

asar extract <archive> <dest>
1赞

3Q :heart_eyes:

你好,请问你的这个问题解决了吗,在程序里面如何进行解包和压包呀,我现在的程序需要修改里面的文件,希望通过程序控制