New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
shelljs seems NOT compatible with nexe under CentOS 6.5 #754
Comments
forget about ./node_modules/shelljs/bin/shjs ./test. |
Please provide a complete minimal setup (i.e. full contents of minimal code files, full configuration necessary, and a sequence of commands to run to produce the bug). I have no experience with nexe, so I get this bug:
|
nexe -i |
@freemine Again, please provide contents of all code files (you can format them with markdown code blocks). And please provide a complete list of commands you run (i.e. the command to run nexe, then command to execute the script, and any error output the commands produce). I tried using nexe but it kicked off a massive compilation, which doesn't sound like the correct behavior for a tiny script. |
sorry for inconvenience.
This is by-default nexe's behavior, for nexe is going to build nodejs code into platform-dependent executables. Again, below is the only file I demo this error. All versions:
test.js as:
steps to follow:
results you might see:
|
@freemine thanks for the update. The steps are clear now. I'll try this out sometime this week and see what I can reproduce. Please ping this bug if I don't get back to it within a week. |
@nfischer just ping in case you're just too busy |
I can reproduce this. It seems like It can't handle this line because we determine which packages to import at runtime (even though it's from a static list in another JS file).
// test.js
const shell = require('shelljs');
shell.echo('good');
I also tried changing the imports to a static list of
As far as I know, everything we're doing is perfectly legal. @freemine could you CC a dev from nexe so we can discuss next steps? |
Is ShellJS doing something nexe explicitly disallows, or is this an oversight by nexe? Please add whomever is the best to answer this. |
@nfischer It looks like the bundler nexe is using is getting hung up on a few of the constructs in the code. The dynamic requires as you highlighted Lines 24 to 26 in c7d65ac
and Line 8 in c7d65ac
Ideally the bundler would be able to handle that pkg#main field, but it must be a bug. I'll see what can be done to handle that case. I'll make these issues and see if we can't get it resolved. In the meantime. A harmless fix is, as you mentioned, Declare the commands explicitly, and in common.js change |
Are you parsing I'm not familiar with |
Yes. The require calls are parsed by the bundler, though nexe's focus is tying in that bundle to a runtime -- Right now we're relying on this bundler to actually assemble the application. It still has some issues I'm trying to identify and work through, hence the rc status... You're not wrong about @freemine As an escape, you can pass Here is the signature
const webpack = require('pify')(require("webpack"))
const fs = require('fs')
module.exports.createBundle = function (options) {
return webpack({
entry: options.input,
target: 'node',
output: { filename: 'tmp.js' }
}).then(() => {
const result = fs.readFileSync('./tmp.js').toString()
fs.unlinkSync('./tmp.js')
return result
})
} Thanks for finding these issues -- It helps alot! |
Thanks for the workaround! 🎉
Why not follow Regardless, the bundler definitely should not strip files from dependencies (npm already does all valid stripping). I know some maintainers don't utilize It's ok to provide I'm going to close this issue (this is a bundler bug, not a ShellJS bug). Let's continue general discussion below and we can reopen if ShellJS really is doing something invalid. |
Right. like I mentioned, nexe didn't try to solve/focus on bundling -- Looks like we might need to re-evaluate the solution that was chosen. |
Node version (or tell us if you're using electron or some other framework):
node: v8.2.1
npm: 5.3.0
nexe: 1.1.3
ShellJS version (the most recent version/Github branch you see the bug on):
shelljs@0.7.8 (npm install shelljs)
Operating system:
CentOS 6.5
uname -a: Linux localhost.localdomain 2.6.32-431.el6.x86_64 #1 SMP Fri Nov 22 03:15:09 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
Description of the bug:
gcc --version: gcc (GCC) 4.9.2 20150212 (Red Hat 4.9.2-6)
using nexe to build a binary from js file which require('shelljs'), the binary could be built.
but when the binary is run, it fails with:
module.js:487
throw err;
^
Error: Cannot find module './src/cat'
at Function.Module._resolveFilename (module.js:485:15)
at Function.Module._load (module.js:437:25)
at Module.require (module.js:513:17)
at require (internal/module.js:11:18)
at s ([eval]:1:114)
at [eval]:1:305
at [eval]:3312:3
at Array.forEach (native)
at Object.16../commands ([eval]:3311:23)
at s ([eval]:1:254)
test.js as simple as such:
let shelljs = require('shelljs');
console.log('d');
but, when I run: node ./test.js, it runs smoothly with no error.
but, when i run: ./node_modules/shelljs/bin/shjs ./test, it runs correctly.
Example ShellJS command to reproduce the error:
The text was updated successfully, but these errors were encountered: