Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Install: npm i nexe -g
Nexe is a command-line utility that compiles your Node.js application into a single executable file.
Application entrypoint:
nexe my-app.js
stdin interface
rollup -c | nexe --resource "./public/**/*" -o my-app.exe
For more CLI options see: nexe --help
nexe server.js -r "public/**/*.html"
nexe --build
nexe -t x86-8.0.0
Additional files or resources can be added to the binary by passing -r "glob/pattern/**/*"
. These included files can be read in the application by using fs.readFile
or fs.readFileSync
.
By default nexe
will attempt to download a pre-built executable. These are listed on the releases page. The exact version you want may be unavailable or you may want to customize what is built. See nexe --help
for a list of options available when passing the --build
option. You will also need to ensure your environment is setup to build node. Note: the python
binary in your path should be an acceptable version of python 3; you can create a symlink or use the --python
parameter (e.g. nexe --build --python=$(which python3)
).
The fastest and most reliable way to get started is simply to run the commands below. If you'd rather read the details or perform a manual install of the prerequisites, you can find that here.
The instructions below are the fastest and most reliable method. Run the following sets of commands with PowerShell (running as Administrator).
Install all required build tools (and dependencies):
Set-ExecutionPolicy Unrestricted -Force
iex ((New-Object System.Net.WebClient).DownloadString('https://boxstarter.org/bootstrapper.ps1'))
get-boxstarter -Force
Install-BoxstarterPackage https://raw.githubusercontent.com/nodejs/node/master/tools/bootstrap/windows_boxstarter -DisableReboots
Set config:
npm config set msvs_version 2019
npm config set python python3.8
Where 2019
is the version of Visual Studio you have (if you have it).
Notes:
14.5.4
and 15.8.0
nexe
will still work, considering the set config
area abovenpm install windows-build-tools
unless you're having some type of issue, because the above commands configures and installs the latest/preferred too.const { compile } = require('nexe')
compile({
input: './my-app.js',
build: true, //required to use patches
patches: [
async (compiler, next) => {
await compiler.setFileContentsAsync(
'lib/new-native-module.js',
'module.exports = 42'
)
return next()
}
]
}).then(() => {
console.log('success')
})
options: object
input: string
output: string
name
with an OS specific extension.target: string | object
'windows-ia32-10.13.0'
each segment is optional, and will be merged with the current environment
Examples: (full list)
'win32-x86-10.13.0
{ platform: 'alpine' }
darwin-10.13.0
linux-x64
macos-10.13.0
build
flag is set, the platform portion of the target is ignored.process
bundle: string | boolean
export function createBundle (options: NexeOptions): Promise<string>
name: string
nexe_${Date.now()}
cwd: string
mangle: boolean
build: boolean
--clean
remote: string
null
asset: string
python: string
python
can be accessednull
flags: string[]
['--expose-gc']
[]
configure: string[]
['--with-dtrace', '--dest-cpu=x64']
[]
make: string[]
[]
vcBuild: string[]
['nosign', 'release']
snapshot: string
null
resources: string[]
['./public/**/*']
[]
temp: string
NEXE_TEMP
~/.nexe
ico: string
--build
to be set.rc: object
{
CompanyName: "ACME Corp",
PRODUCTVERSION: "17,3,0,0",
FILEVERSION: "1,2,3,4"
...
}
{}
clean: boolean
enableNodeCli: boolean
--without-node-options
configure flag.false
fakeArgv: boolean
process.argv[1]
). If nexe was used with stdin this will be '[stdin]'
.ghToken: string
process.env.GITHUB_TOKEN
sourceUrl: string
loglevel: string
'info'
patches: NexePatch[]
[]
plugins: NexePatch[]
[]
NexePatch: (compiler: NexeCompiler, next: () => Promise<void>) => Promise<void>
Patches and Plugins are just a middleware functions that take two arguments, the compiler
, and next
. The compiler is described below, and next
ensures that the pipeline continues. Its invocation should always be awaited or returned to ensure correct behavior. Patches also require that --build
be set, while plugins do not.
For examples, see the built in patches: src/patches.
NexeCompiler
setFileContentsAsync(filename: string, contents: string): Promise<void>
replaceInFileAsync(filename: string, ...replaceArgs): Promise<void>
String.prototype.replace
readFileAsync(filename: string): Promise<NexeFile>
addResource(filename: string, contents: Buffer): Promise<void>
files: NexeFile[]
NexeFile
contents: string
absPath: string
filename: string
Any modifications made to NexeFile#contents
will be maintained in the cache without the need to explicitly write them back out, e.g. using NexeCompiler#setFileContentsAsync
.
In order to use native modules, the native binaries must be shipped alongside the binary generated by nexe.
Error: Entry file "" not found!
means you need to provide nexe
with input. Either use -i
or pipe data to it.
Error: https://github.com/nexe/nexe/releases/download/v3.3.3/windows-x64-15.8.0 is not available, create it using the --build flag
or similar message means that it either:
nexe
knows what version of the executable to use.
nexe -i "app.js" -r "public/**/*.html" -o "dist/myApp.exe" -t x64-14.15.3
-i
specifies the input, -r
specifies resources to embed, -o
specifies the output, -t
specifies the target.Building
$ git clone git@github.com:nexe/nexe.git
$ cd nexe
$ npm i && npm run build
Testing
$ npm test
FAQs
Create a single executable out of your Node.js application
We found that nexe demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.