When I run tsc
in my project's directory it outputs an error (reproduced later)
This is the first time I'm trying typescript and nodejs. You can safely assume I'm a total beginner.
- ubuntu 15.10 64bits
- npm version 2.4.12
- node version v4.3.1
- tsc version 1.7.5
- system locale fr_FR.UTF-8
Compiler output :
/data/code/tsrest$ tsc
/usr/lib/node_modules/typescript/lib/tsc.js:31084
var jsonOptions = json["compilerOptions"];
^
TypeError: Cannot read property 'compilerOptions' of undefined
at getCompilerOptions (/usr/lib/node_modules/typescript/lib/tsc.js:31084:35)
at Object.parseJsonConfigFileContent (/usr/lib/node_modules/typescript/lib/tsc.js:31074:22)
at parseConfigFile (/usr/lib/node_modules/typescript/lib/tsc.js:31351:40)
at performCompilation (/usr/lib/node_modules/typescript/lib/tsc.js:31362:45)
at Object.executeCommandLine (/usr/lib/node_modules/typescript/lib/tsc.js:31336:9)
at Object.<anonymous> (/usr/lib/node_modules/typescript/lib/tsc.js:31635:4)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
Project layout:
-rw-rw-r-- 1 220 févr. 20 17:15 package.json
-rw-rw-r-- 1 375 févr. 20 17:39 tsconfig.json
-rw-rw-r-- 1 70 févr. 20 17:23 typings.json
build:
total 8
drwxrwxr-x 2 4096 févr. 20 17:16 ./
drwxrwxr-x 6 4096 févr. 20 17:37 ../
client:
total 8
drwxrwxr-x 2 4096 févr. 20 17:16 ./
drwxrwxr-x 6 4096 févr. 20 17:37 ../
server:
total 12
drwxrwxr-x 2 4096 févr. 20 17:18 ./
drwxrwxr-x 6 4096 févr. 20 17:37 ../
-rw-rw-r-- 1 298 févr. 20 16:59 tsrest.ts
typings:
total 8
drwxrwxr-x 2 4096 févr. 20 17:23 ./
drwxrwxr-x 6 4096 févr. 20 17:37 ../
-rw-rw-r-- 1 0 févr. 20 17:23 browser.d.ts
-rw-rw-r-- 1 0 févr. 20 17:23 main.d.ts
Some of the things I've tried:
cd tsrest
npm init -y
mkdir server build client
(editing tsconfig.json and server/tsrest.ts from a tutorial)
tsc
Outputs the error
sudo npm install -g typings
typings install
tsc
Well that didn't help either.
cd server/
tsc
cd ..
Now I thought my tsconfig.json was not good.
rm tsconfig.json
tsc --init
ll
tsc
Same error ...
Contents of tsconfig.json:
{
"version": "1.7.5",
"compilerOptions": {
"module": "commonjs",
"target": "es5",
"noImplicitAny": false,
"outDir": "built",
"rootDir": ".",
"emitDecoratorMetadata": true,
"experimentalDecorators": true
// "sourceMap": false
},
"exclude": [
"node_modules",
"client" // 4
]
}
Contents of package.json:
{
"name": "tsrest",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC"
}
tsconfig.json
look like? – Vadim Macagon/data/code/tsrest
from where you are running tsc command, the root folder of your project? Also just to confirm, tsconfig.json is in the root folder of your project right? I just did a typescript test on ubuntu 15 64 bits and things ran just fine... my config [node - 5.6.0, npm 3.6.0, tsc @next] – Seshu Kumar Alluvada/data/code/tsrest
is the root folder of my project and tsconfig.json is in the root folder of my project. – David V.