当我tsc在终端中运行时(无论在哪里)我都会返回:
$ npx tsc --version
This is not the tsc command you are looking for
To get access to the TypeScript compiler, tsc, from the command line either:
- Use npm install typescript to first add TypeScript to your project before using npx
- Use yarn to avoid accidentally running code from un-installed packages
Run Code Online (Sandbox Code Playgroud)
据我所知,我没有在全球范围内安装 TypeScript,所以我期望它找不到tsc.
我想安装并运行Typescript(即没有全局依赖).
这是我的package.json文件:
{
"name": "foo",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"tsc": "tsc"
},
"devDependencies": {
"typescript": "^1.8.10"
},
"author": "",
"license": "ISC"
}
Run Code Online (Sandbox Code Playgroud)
然后我跑:
npm install
npm run tsc
Run Code Online (Sandbox Code Playgroud)
但是,当我运行第二个命令时,我得到很多错误,它无法显示所有错误.大部分内容如下:
../foo/node_modules/typescript/lib/lib.d.ts(5015,5): error TS2300: Duplicate identifier 'webkitTransformOrigin'.
../foo/node_modules/typescript/lib/lib.d.ts(5016,5): error TS2300: Duplicate identifier 'webkitTransformStyle'.
../foo/node_modules/typescript/lib/lib.d.ts(5017,5): error TS2300: Duplicate identifier 'webkitTransition'.
../foo/node_modules/typescript/lib/lib.d.ts(5018,5): error TS2300: Duplicate identifier 'webkitTransitionDelay'.
../foo/node_modules/typescript/lib/lib.d.ts(5019,5): error TS2300: Duplicate identifier 'webkitTransitionDuration'.
../foo/node_modules/typescript/lib/lib.d.ts(5020,5): error TS2300: Duplicate identifier 'webkitTransitionProperty'.
Run Code Online (Sandbox Code Playgroud)
在npm-debug.log中我得到:
0 …Run Code Online (Sandbox Code Playgroud) 所以我做了ng -v它向我展示除了打字稿之外的一切,所以我如何检查我的角度4项目的Typescript版本.
在本地测试我以前运行:
"build-live": "nodemon --exec ./node_modules/.bin/ts-node -r dotenv/config -- ./index.ts"
Run Code Online (Sandbox Code Playgroud)
然后我想我的Procfile应该是这样的:
web: ./node_modules/.bin/ts-node -- ./index.ts
Run Code Online (Sandbox Code Playgroud)
但它说模块'typescript'没有找到,即使它在package.json.我在几个地方读到了ts-node不能部署到Heroku的方法,所以我不知道该怎么办.
更新:我想我应该编译它,所以我试过:
web: ./node_modules/.bin/tsc --module commonjs --allowJs --outDir build/ --sourceMap --target es6 index.ts && node build/index.js
Run Code Online (Sandbox Code Playgroud)
这成功了,但是当实际运行它时,我正在使用的一堆lib得到"找不到模块'......'".
我正在为一个项目设置 Gitlab CI docker-in-docker。不幸的是,该作业一直失败,因为在运行命令时似乎找不到已安装的 NPM 包。我得到的错误:
backend_1 |
backend_1 | > tacta-backend@0.0.1 build /app
backend_1 | > tsc
backend_1 |
backend_1 | sh: tsc: not found
backend_1 | npm ERR! file sh
backend_1 | npm ERR! code ELIFECYCLE
backend_1 | npm ERR! errno ENOENT
backend_1 | npm ERR! syscall spawn
backend_1 | npm ERR! tacta-backend@0.0.1 build: `tsc`
backend_1 | npm ERR! spawn ENOENT
backend_1 | npm ERR!
backend_1 | npm ERR! Failed at the tacta-backend@0.0.1 build script.
backend_1 | npm …Run Code Online (Sandbox Code Playgroud)