ReactiveX / rxjs-tslint

TSLint rules targeting RxJS
MIT License
309 stars 41 forks source link

Error: Cannot find module 'typescript' #47

Closed dwilches closed 6 years ago

dwilches commented 6 years ago

While running this command: rxjs-5-to-6-migrate -p src/tsconfig.app.json I get the following error:

Running the automatic migrations. Please, be patient and wait until the execution completes.
module.js:549
    throw err;
    ^

Error: Cannot find module 'typescript'
    at Function.Module._resolveFilename (module.js:547:15)
    at Function.Module._load (module.js:474:25)
    at Module.require (module.js:596:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/usr/local/lib/node_modules/rxjs-tslint/node_modules/tslint/lib/linter.js:22:10)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
child_process.js:644
    throw err;
    ^

Error: Command failed: "/usr/local/lib/node_modules/rxjs-tslint/node_modules/.bin/tslint" -c "/usr/local/lib/node_modules/rxjs-tslint/rxjs-5-to-6-migrate.json" -p "src/tsconfig.app.json" --fix
module.js:549
    throw err;
    ^

Error: Cannot find module 'typescript'
    at Function.Module._resolveFilename (module.js:547:15)
    at Function.Module._load (module.js:474:25)
    at Module.require (module.js:596:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/usr/local/lib/node_modules/rxjs-tslint/node_modules/tslint/lib/linter.js:22:10)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)

    at checkExecSyncError (child_process.js:601:13)
    at Object.execSync (child_process.js:641:13)
    at migrate (/usr/local/lib/node_modules/rxjs-tslint/rxjs-5-to-6-migrate.js:18:34)
    at Object.<anonymous> (/usr/local/lib/node_modules/rxjs-tslint/rxjs-5-to-6-migrate.js:25:14)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
    at Module.require (module.js:596:17)

I checked my package.json and I see I have typescript among my devDependencies, and I vlaidated it like this:

$ yarn list | grep typescript
│  ├─ typescript@~2.9.1
│  ├─ typescript@>=2.6.2 <2.8
│  └─ typescript@2.7.2
├─ typescript@2.9.2

I also tried installing typescript globally with yarn add global typescript.

What can be the reason for this error?

dwilches commented 6 years ago

Running this, solved the problem: sudo npm i -g typescript I thought that was doing the exact same as yarn add global typescript that I had already executed, but seems not.