Skip to content

can't run samples #1

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

Closed
ichiriac opened this issue Dec 23, 2016 · 5 comments
Closed

can't run samples #1

ichiriac opened this issue Dec 23, 2016 · 5 comments

Comments

@ichiriac
Copy link

Hi @DaGhostman,

When I run it from the command line, I got this error :

/usr/local/lib/node_modules/ts-node/src/index.ts:312
          throw new TSError(formatDiagnostics(diagnosticList, cwd, ts, lineOffset))
                ^
TSError: ⨯ Unable to compile TypeScript
bin/php-inspections.ts (3,21): Cannot find module 'fs'. (2307)
bin/php-inspections.ts (9,5): Cannot find name 'process'. (2304)
bin/php-inspections.ts (18,5): Cannot find name 'process'. (2304)
bin/php-inspections.ts (20,5): Cannot find name 'process'. (2304)
bin/php-inspections.ts (23,20): Cannot find name 'process'. (2304)
bin/php-inspections.ts (23,33): Cannot find name 'process'. (2304)
bin/php-inspections.ts (23,75): Cannot find name 'process'. (2304)
bin/php-inspections.ts (23,88): Cannot find name 'process'. (2304)
bin/php-inspections.ts (27,5): Cannot find name 'process'. (2304)
bin/php-inspections.ts (36,5): Cannot find name 'process'. (2304)
bin/php-inspections.ts (40,14): Cannot find name 'process'. (2304)
bin/php-inspections.ts (47,17): Cannot find name 'process'. (2304)
bin/php-inspections.ts (48,28): Cannot find name 'process'. (2304)
    at getOutput (/usr/local/lib/node_modules/ts-node/src/index.ts:312:17)
    at /usr/local/lib/node_modules/ts-node/src/index.ts:343:18
    at Object.compile (/usr/local/lib/node_modules/ts-node/src/index.ts:502:17)
    at Module.m._compile (/usr/local/lib/node_modules/ts-node/src/index.ts:406:44)
    at Module._extensions..js (module.js:417:10)
    at Object.require.extensions.(anonymous function) [as .ts] (/usr/local/lib/node_modules/ts-node/src/index.ts:409:12)
    at Module.load (module.js:344:32)
    at Function.Module._load (module.js:301:12)
    at Function.Module.runMain (module.js:442:10)
    at Object.<anonymous> (/usr/local/lib/node_modules/ts-node/src/_bin.ts:184:12)

I'm running it from ubuntu 16, ts-node v1.7.2 and node v4.2.6.

Any clue ?

@DaGhostman
Copy link
Owner

DaGhostman commented Dec 23, 2016

Just was able to reproduce the issue. Turns out I have some global types that ts-node uses and that ended in the tool not working (I was soo excited 😆 ) + I was able to identify a slight incompatibility with node:4 (I was using 6 while developing) the fix takes a few steps actually:

  1. Update the devDependencies to ask for ~4.0 of `@types/node"
  2. Point to set typeRoots in tsconfig.json to node_modules/@types/
  3. add import * as process from 'process' in the bin/php-inspections.ts

I will commit the fix in a few mins


As far as I can tell 0a71ec9 resolves the issue, mind verifying for me :)

@ichiriac
Copy link
Author

ichiriac commented Dec 23, 2016

Iit's better, the list of error is smaller :

/usr/local/lib/node_modules/ts-node/src/index.ts:312
          throw new TSError(formatDiagnostics(diagnosticList, cwd, ts, lineOffset))
                ^
TSError: ⨯ Unable to compile TypeScript
bin/php-inspections.ts (3,21): Cannot find module 'fs'. (2307)
bin/php-inspections.ts (4,26): Cannot find module 'process'. (2307)
    at getOutput (/usr/local/lib/node_modules/ts-node/src/index.ts:312:17)
    at /usr/local/lib/node_modules/ts-node/src/index.ts:343:18
    at Object.compile (/usr/local/lib/node_modules/ts-node/src/index.ts:502:17)
    at Module.m._compile (/usr/local/lib/node_modules/ts-node/src/index.ts:406:44)
    at Module._extensions..js (module.js:417:10)
    at Object.require.extensions.(anonymous function) [as .ts] (/usr/local/lib/node_modules/ts-node/src/index.ts:409:12)
    at Module.load (module.js:344:32)
    at Function.Module._load (module.js:301:12)
    at Function.Module.runMain (module.js:442:10)
    at Object.<anonymous> (/usr/local/lib/node_modules/ts-node/src/_bin.ts:184:12)

maybe it's the same reason : microsoft/TypeScript#5812

@ichiriac
Copy link
Author

found the solution here : http://stackoverflow.com/questions/37260901/how-to-find-module-fs-in-ms-code-with-typescript

npm install typings --global
typings install dt~node --global --save

And after everything runs well 😄

@DaGhostman
Copy link
Owner

DaGhostman commented Dec 23, 2016

Lol I was just getting desperate... I was going to set up docker just to reproduce 😄 Anyway, Ill add it to the README


But still it should see the typings inside the node_modules directory, unless I am missing something with ts-node

@ichiriac
Copy link
Author

oups, i've made a npm install after getting the unable to find php-parser error :(

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

2 participants