fuse-box/fuse-box

TypeError: Cannot read property 'filename' of undefined

evan-boissonnot opened this issue · 4 comments

Hi,

I'm using : "fuse-box": "^4.0.1-next.8",
When I run node fuse, to my file fuse.js, got the prob :

node_modules\fuse-box\env.js:20
SCRIPT_FILE: require.main.filename,

here my fuse.js file :
import { fusebox } from 'fuse-box';
const fuse = fusebox({
entry: 'src/main.ts',
target: 'browser',
devServer: true,
webIndex: {
template: 'src/index.html',
},
webIndex: true,
});

fuse.runDev();

I have got just one file : main.ts, in the src directory
and of course index.html inside too

what's that

webIndex: {
template: 'src/index.html',
},
webIndex: true,

It really should work, please check a lot examples in the playground folder

I have same issue. node 14.18.1, with type: module in package.json

ypeError: Cannot read property 'filename' of undefined
    at Object.<anonymous> (/Users/joshpike/Projects/formpigeon/node_modules/fuse-box/env.js:20:31)
    at Module._compile (internal/modules/cjs/loader.js:1085:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
    at Module.load (internal/modules/cjs/loader.js:950:32)
    at Function.Module._load (internal/modules/cjs/loader.js:790:12)
    at Module.require (internal/modules/cjs/loader.js:974:19)
    at require (internal/modules/cjs/helpers.js:93:18)
    at Object.<anonymous> (/Users/joshpike/Projects/formpigeon/node_modules/fuse-box/utils/utils.js:10:15)
    at Module._compile (internal/modules/cjs/loader.js:1085:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)

Problem is using es6 modules mode, these lines in env.js aren't calculated properly:

SCRIPT_FILE: require.main.filename,
SCRIPT_PATH: path.dirname(require.main.filename),

Changing them to this worked:

    SCRIPT_FILE: appRoot.path + 'fuse.js',
    SCRIPT_PATH: appRoot.path,