无法在OS X中通过终端安装tsc

时间:2015-09-05 04:28:54

标签: node.js terminal npm typescript tsc

我正在尝试安装tsc,但是当我运行它时,我遇到了很多错误。

我现在尝试重新安装node和npm至少三次,但无济于事。我为我的npm设置了详细的标志,这就是我得到的:

Mitch:~ mitch$ npm install -g typescript
npm info it worked if it ends with ok
npm verb cli [ '/usr/local/bin/node',
npm verb cli   '/usr/local/bin/npm',
npm verb cli   'install',
npm verb cli   '-g',
npm verb cli   'typescript' ]
npm info using npm@2.11.3
npm info using node@v0.12.7
npm verb install initial load of /usr/local/lib/package.json
npm verb readDependencies loading dependencies from /usr/local/lib/package.json
npm verb cache add spec typescript
npm verb addTmpTarball /Users/mitch/typescript not in flight; adding
npm verb addTmpTarball validating metadata from /Users/mitch/typescript
npm verb tar unpack /Users/mitch/typescript
npm verb tar unpacking to /var/folders/32/tx_f6y6d6d39nh3018kkzfyh0000gn/T/npm-48973-ca0b016f/unpack-9e1778f4fdd1
npm verb gentlyRm don't care about contents; nuking /var/folders/32/tx_f6y6d6d39nh3018kkzfyh0000gn/T/npm-48973-ca0b016f/unpack-9e1778f4fdd1
npm ERR! not a package /Users/mitch/typescript
npm ERR! addLocal Could not install /Users/mitch/typescript
npm verb stack Error: ENOENT, open '/var/folders/32/tx_f6y6d6d39nh3018kkzfyh0000gn/T/npm-48973-ca0b016f/unpack-9e1778f4fdd1/package.json'
npm verb stack     at Error (native)
npm verb cwd /Users/mitch
npm ERR! Darwin 14.4.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "-g" "typescript"
npm ERR! node v0.12.7
npm ERR! npm  v2.11.3
npm ERR! path /var/folders/32/tx_f6y6d6d39nh3018kkzfyh0000gn/T/npm-48973-ca0b016f/unpack-9e1778f4fdd1/package.json
npm ERR! code ENOENT
npm ERR! errno -2

npm ERR! enoent ENOENT, open '/var/folders/32/tx_f6y6d6d39nh3018kkzfyh0000gn/T/npm-48973-ca0b016f/unpack-9e1778f4fdd1/package.json'
npm ERR! enoent This is most likely not a problem with npm itself
npm ERR! enoent and is related to npm not being able to find a file.
npm ERR! enoent 
npm verb exit [ -2, true ]

npm ERR! Please include the following file with any support request:
npm ERR!     /Users/mitch/npm-debug.log

我很茫然。我用谷歌搜索了大量的页面,这似乎对其他人都很好,或者他们只是有不同的错误。知道问题是什么吗?

这是我当前的bash_profile,安装了node和npm:

export PATH="$HOME/usr/local/bin:./node_modules/.bin:$PATH"

让我知道你们还有什么需要帮助我的,谢谢!

1 个答案:

答案 0 :(得分:1)

所以,我最终找到了解决方案。我不确定为什么,但是

npm install -g typescript

工作,但是,出于我的挫败感,当我尝试

npm install -g typescript@last

它完美无缺,我已经使用Visual Studio Code和终端进行了测试。如果这在Windows上运行,我无法评论。我想你现在只需npm夜间建造?奇怪的东西。谢谢你的努力!