Skip to content
This repository has been archived by the owner on Jun 20, 2023. It is now read-only.

TypeError: Cannot read property 'filename' of undefined #2030

Open
evan-boissonnot opened this issue Nov 30, 2021 · 4 comments
Open

TypeError: Cannot read property 'filename' of undefined #2030

evan-boissonnot opened this issue Nov 30, 2021 · 4 comments

Comments

@evan-boissonnot
Copy link

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();

@evan-boissonnot
Copy link
Author

evan-boissonnot commented Nov 30, 2021

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

@nchanged
Copy link
Contributor

nchanged commented Dec 9, 2021

what's that

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

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

@jpike88
Copy link
Contributor

jpike88 commented Dec 23, 2021

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)

@jpike88
Copy link
Contributor

jpike88 commented Dec 23, 2021

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,

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants