Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
368 views
in Technique[技术] by (71.8m points)

javascript - excluding config file while converting node js files to exe using pkg

I'm developing a node.js application. To make the application unreadable for users, I'm trying to convert js files to exe. I'm using pkg to convert my files but got an issue. pkg module does convert all of my project to exe, but I have a config file in the directory that I don't want it to be converted.

this config files is used to get user's credentials and custom configs and load that in my project. unfortunately the config file which is written in json will be added to my exe file and cannot be edited after compiling. I've read the documentation of pkg module but didn't find anything useful. I'll be thankful If any one can suggest a solution for my problem,or if there is any other solution for protecting the code

Thanks.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Finally found my mistake. I was requiring the config file in my javascript program which made pkg module to count config files as main program files and then packages them in the exe file. Instead I had to use read content of the file so the config file doesn't count in my program's files. Using fs.readFile() solved the issue.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...