ts-loader: Cannot find typings with typescript@beta and @type

My problem same as in https://github.com/TypeStrong/ts-loader/issues/243

After installing @types/node i got multiple errors:

(1,21): error TS2307: Cannot find module 'fs'.
(3,23): error TS2307: Cannot find module 'path'.
(80,41): error TS2304: Cannot find name 'process'.
(5,12): error TS2304: Cannot find name 'global'.
(6,5): error TS2304: Cannot find name 'require'.

I add all definitions to types

But as said https://github.com/mhegazy in https://github.com/DefinitelyTyped/DefinitelyTyped/issues/10113#issuecomment-233199963

you should not need to add the types property, the behavior should be the same with or without it

2.0.0-beta compiler.

project: https://github.com/sanex3339/javascript-obfuscator/tree/dev

project tsconfig:

{
  "compilerOptions": {
    "target": "ES6",
    "module": "commonjs",
    "sourceMap": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "removeComments": true,
    "noImplicitAny": true,
    "strictNullChecks": true,
    "noUnusedLocals": true
  }
}

entry point

"use strict";

import { JavaScriptObfuscator } from './src/JavaScriptObfuscator';

if (!(<any>global)._babelPolyfill) {
    require('babel-polyfill');
}

module.exports = JavaScriptObfuscator;

to reproduce you must clone dev branch, and run node_modules/.bin/webpack --watch

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Reactions: 14
  • Comments: 20 (9 by maintainers)

Commits related to this issue

Most upvoted comments

Resolved - 🚢 with 0.9.2

My fork has added types support, but still cannot get all tests passed. You can also have a look on awesome typescript loader.

@QuantumInformation Please don’t fill up issues with unrelated problems. If you need help, there’s Gitter, Google or a new issue.

Most likely, some package you’ve installed specifies a peer dependency on webpack that is different to the version you have installed.

Edit: If you did an npm ls, which it looks like you did, it probably says along the bottom what the issue is. For instance, mine says “peer dep missing: x@x, required by x@x”.

I believe this is a fairly trivial fix to do, but I haven’t been working on the project as the state of the tests are broken. If someone would care to improve the situation, I can work on new features.