[go: nahoru, domu]

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

TypeError: Cannot read property 'prototype' of undefined #295

Open
Hertox82 opened this issue Dec 15, 2017 · 3 comments
Open

TypeError: Cannot read property 'prototype' of undefined #295

Hertox82 opened this issue Dec 15, 2017 · 3 comments

Comments

@Hertox82
Copy link

Hi,

this is my enviroment:

  • Node : v6.11.3
  • macOS: 10.13.1

this is my package.json:

{
"devDependencies": {
    "@types/archiver": "^2.0.1",
    "@types/npm": "^2.0.29",
    "archiver": "^2.1.0",
    "ts-loader": "^3.2.0",
    "typescript": "^2.6.2",
    "webpack": "^3.10.0"
  }
}

this my tsconfig.json:

{
 "compilerOptions": {
      "target": "es5",
      "module": "commonjs",
      "outDir": "dist",
      "moduleResolution": "node",
      "emitDecoratorMetadata": true,
      "experimentalDecorators": true,
      "sourceMap": true,
      "declaration": true,
      "baseUrl": "src",
      "typeRoots": [
          "node_modules/@types"
      ],
      "lib":[
          "es2017",
          "dom"
      ]
    },
}

and finally this is my code:

import * as path from 'path'; 
import * as fs from 'fs';
import * as archiver from 'archiver';
const folderPath = path.resolve(__dirname+'/../tozip/');

const output = fs.createWriteStream('my-tarball.tar');
const arch = archiver('tar');
arch.pipe(output);
arch.directory(folderPath,folderPath);
arch.finalize();

after build, and run node... this is my output:

ReadStream.prototype = Object.create(fs$ReadStream.prototype)
                                                    ^
TypeError: Cannot read property 'prototype' of undefined

Anyone have any idea for this behavior?

thank you

@Hertox82
Copy link
Author

OK, i'm solved this issue adding this into my webpack.config.js file:

module.exports = {
   /* other options*/
    target: 'node',
    node: {
        fs: 'empty'
    }
/* ... */
}

@justinlevi
Copy link

I'm running into the same issue. Is there a way to handle this without overriding the webpack.config.js?

@ctalkington
Copy link
Member

so this is a webpack issue with node fs then?

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