question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error combining with 6to5ify

See original GitHub issue

I’m trying to do a brfs transform after 6to5ify, but get the following error.

browserify()
    .require("main", { entry: true })
    .transform(6to5ify)
    .transform(brfs)
    .bundle()
    .pipe(fs.createWriteStream(path.join('app.js')));
events.js:72
        throw er; // Unhandled 'error' event
              ^
Error: tried to statically call { readFile: [Function: readFile], readFileSync: [Function: readFileSync], readdir: [Function: readdir], readdirSync: [Function: readdirSync] } as a function while parsing file: /Users/akula/foo/main.js while parsing file: /Users/akula/foo/main.js
    at error (/Users/akula/foo/node_modules/brfs/node_modules/static-module/index.js:71:49)
    at traverse (/Users/akula/foo/node_modules/brfs/node_modules/static-module/index.js:247:24)
    at walk (/Users/akula/foo/node_modules/brfs/node_modules/static-module/index.js:216:13)
    at walk (/Users/akula/foo/node_modules/brfs/node_modules/static-module/node_modules/falafel/index.js:60:9)
    at /Users/akula/foo/node_modules/brfs/node_modules/static-module/node_modules/falafel/index.js:51:25
    at Array.forEach (native)
    at forEach (/Users/akula/foo/node_modules/brfs/node_modules/static-module/node_modules/falafel/index.js:8:31)
    at /Users/akula/foo/node_modules/brfs/node_modules/static-module/node_modules/falafel/index.js:49:17
    at Array.forEach (native)
    at forEach (/Users/akula/foo/node_modules/brfs/node_modules/static-module/node_modules/falafel/index.js:8:31)

btw, there’s a double “while parsing file” in the message.

My main.js looks like this.

import fs from 'fs';

var foo = fs.readFileSync(__dirname + '/foo.html');
console.log(foo.toString());

If I change the import to a require and don’t do 6to5ify it works fine, but together it gives the error.

Issue Analytics

  • State:open
  • Created 9 years ago
  • Comments:12

github_iconTop GitHub Comments

6reactions
danharpercommented, Mar 5, 2015

I’m guessing this is down to how Babel (was: 6to5) transpiles ES6 imports. This:

import fs from 'fs'

Becomes this:

var _interopRequire = function (obj) { return obj && obj.__esModule ? obj["default"] : obj; };

var fs = _interopRequire(require("fs"));

If you want to go this route, resorting to a regular require call works fine:

var fs = require('fs');
3reactions
erykpiastcommented, Feb 5, 2015

But it works perfectly fine when used like

var fs = require('fs');
var content = fs.readFileSync(__dirname + '/file', 'utf8');

I don’t have to disable 6to5.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error handling in Combine explained with code examples
Error handling in Swift Combine explained by covering operators like mapError, catch, replaceError, assertOnFailure, and how to map to the ...
Read more >
How to import widgets from NPM package - Open Q&A
When we try to npm install and import the modules like in the examples we get an error in our gulp setup. We...
Read more >
Untitled
Sbl-eai-04451 error in siebel, Folkem kft debrecen, Rere atu rere mai, ... 963 google play error, Greek national opera atene, Owsinski mixing pdf, ......
Read more >
Error with combining lists - data
Error with combining lists ... I'm attempting to combine lists of the form. In: PressureChange = Data[[All,{3}]]//ToExpression; Out: {{0.19} ...
Read more >
Untitled
Momc error, Is there a notebook 2 movie, Diocesis tacna y moquegua 2014, ... Mouserate windows 8.1, Over ripe bananas gas, Browserify 6to5ify,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found