Skip to content
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

Resolution Errors while trying to bundle and minify Node cli source files #364

Closed
enterprisecoderr opened this issue Sep 2, 2020 · 6 comments

Comments

@enterprisecoderr
Copy link

I installed esbuild and rand the following command but received a bunch of errors. Is there something that I'm missing from the docs?

Input:

node_modules/.bin/esbuild  bin/test.js --bundle '--define:process.env.NODE_ENV="production"' --minify --outfile=out.js

Output

bin/wcr.js:2:0: warning: Indirect calls to "require" will not be bundled
require = require('esm')(module /* , options*/);
~~~~~~~
node_modules/esm/esm.js:1:761: warning: Indirect calls to "require" will not be bundled
...nction x(e,n){return null!=e&&t(l,e,[n])}function D(){return M(require,w,T),w.exports}function O(e,t){return D()(e,t)}function j(e,t)...
                                                                  ~~~~~~~
node_modules/esm/esm.js:1:366: error: Could not resolve "module"
...ith("internal/")&&(d=q("internal/esm/loader"));const f=require("module"),{Script:m}=require("vm"),{createCachedData:y,runInNewContext...
                                                                  ~~~~~~~~
node_modules/dotenv/lib/main.js:24:19: error: Could not resolve "fs"
const fs = require('fs')
                   ~~~~
src/main.js:1:15: error: Could not resolve "fs"
import fs from 'fs';
               ~~~~
node_modules/esm/esm.js:1:395: error: Could not resolve "vm"
...ernal/esm/loader"));const f=require("module"),{Script:m}=require("vm"),{createCachedData:y,runInNewContext:h,runInThisContext:b}=m.pr...
                                                                    ~~~~
node_modules/dotenv/lib/main.js:25:21: error: Could not resolve "path"
const path = require('path')
                     ~~~~~~
node_modules/esm/esm.js:1:487: error: Could not resolve "path"
...nInNewContext:h,runInThisContext:b}=m.prototype,{sep:g}=require("path"),{readFileSync:v}=require("fs"),w=new f(s);function q(e){let t...
                                                                   ~~~~~~
src/main.js:1:17: error: Could not resolve "path"
import path from 'path';
                 ~~~~~~
node_modules/esm/esm.js:1:520: error: Could not resolve "fs"
...:b}=m.prototype,{sep:g}=require("path"),{readFileSync:v}=require("fs"),w=new f(s);function q(e){let t;try{const{internalBinding:n}=re...
                                                                    ~~~~
src/main.js:1:26: error: Could not resolve "util"
import { promisify } from 'util';
                          ~~~~~~
node_modules/inquirer/lib/ui/baseUI.js:4:23: error: Could not resolve "readline"
var readline = require('readline');
                       ~~~~~~~~~~
2 warnings and 10 errors reached (disable error limit with --error-limit=0)
@evanw
Copy link
Owner

evanw commented Sep 2, 2020

If you are bundling something for node, you should be using --platform=node. Does that work for you?

@lakshay35
Copy link

That does work but it seems like the output file permissions restricted the user from accessing it. Is there another flag I need to pass to fix that?

@evanw
Copy link
Owner

evanw commented Sep 2, 2020

I’m not sure what you mean by permissions. Could you provide more information? For example, are you on Unix and expecting the executable permission bit to be set on the output file? Does chmod +x not work for you? Or is the issue the read permission bit?

@lakshay35
Copy link

chmod works

@evanw
Copy link
Owner

evanw commented Sep 9, 2020

Are you perhaps using a script starting with a #! hashbang line?

@lakshay35
Copy link

lakshay35 commented Sep 9, 2020 via email

@evanw evanw closed this as completed in b808c0d Sep 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants