2

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

我现在尝试重新安装 node 和 npm 至少 3 次,但无济于事。我为我的 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"

如果还有什么需要帮助的,请告诉我,谢谢!

4

1 回答 1

1

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

npm install -g typescript

行不通,但是,出于我的挫败感,当我尝试

npm install -g typescript@last

它完美无缺,我已经使用 Visual Studio Code 和终端对其进行了测试。我无法评论这是否适用于 Windows。我猜你现在只需要npm每晚构建?奇怪的东西。不过感谢您的努力!

于 2015-09-05T06:29:22.100 回答