最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Node JS unable to execute asar archive - Stack Overflow

programmeradmin1浏览0评论

Pretty simple. I am on Windows 8, I used the asar module to package a folder containing a node app.

I ran node app.asar and got the error

SyntaxError: Unexpected token ILLEGAL at exports.runInThisContext (vm.js:53:16) "(function (exports, require, module, __filename, __dirname) { ?"

where ? is clearly an invalid character.

Why does this archive contain invalid characters if I can run the app without issue before packaging it and asar archives are supposedly readable to a nodejs process

Pretty simple. I am on Windows 8, I used the asar module to package a folder containing a node app.

I ran node app.asar and got the error

SyntaxError: Unexpected token ILLEGAL at exports.runInThisContext (vm.js:53:16) "(function (exports, require, module, __filename, __dirname) { ?"

where ? is clearly an invalid character.

Why does this archive contain invalid characters if I can run the app without issue before packaging it and asar archives are supposedly readable to a nodejs process

Share Improve this question asked Dec 7, 2016 at 14:24 Daniel OlivierDaniel Olivier 1832 silver badges10 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 7

You can't run asar packed file as normal Nodejs app, that's because asar is designed for Electron, not for ordinary Nodejs app. BUT! Try to install the electron as your project dependency or just ordinary modules

npm install electron

or install it globally

npm install -g electron

so you don't have to re install it on every project you have to run the packed asar file

and some notice: installing Electron is a bit longer because it's not normal modules

after you've done with the installation, try

electron file.asar

and test it if the app run as normal nodejs app

EDIT: maybe some time in near future you want try to package your "Nodejs App" with asar so the clien't wouldn't see your source code, and then deploy it to your client

here is the Electron way to publish your Electron App ( but perhaps, it can be used for another app as well ) GitHub Link

发布评论

评论列表(0)

  1. 暂无评论