无法安装NodeJS模块

时间:2014-01-05 08:56:27

标签: node.js typescript karma-runner

我正在尝试安装名为“karma-typescript-preprocessor”的NodeJS模块(参见:https://npmjs.org/package/karma-typescript-preprocessor),但在尝试安装时遇到错误。 Karma在测试之前使用它来编译打字稿文件。这是我得到的错误。我该如何解决这个问题?

C:\Users\Me\WebstormProjects\Core>npm install karma-typescript-preprocessor
npm http GET https://registry.npmjs.org/karma-typescript-preprocessor
npm http 304 https://registry.npmjs.org/karma-typescript-preprocessor
npm ERR! Error: No compatible version found: karma-typescript-preprocessor@'>=0.1.0-0 <0.2.0-0'
npm ERR! Valid install targets:
npm ERR! ["0.0.2","0.0.4","0.0.5","0.0.6"]
npm ERR!     at installTargetsError (C:\Program Files (x86)\nodejs\node_modules\npm\lib\cache.js:719:10)
npm ERR!     at next (C:\Program Files (x86)\nodejs\node_modules\npm\lib\cache.js:698:17)
npm ERR!     at C:\Program Files (x86)\nodejs\node_modules\npm\lib\cache.js:675:5
npm ERR!     at saved (C:\Program Files (x86)\nodejs\node_modules\npm\node_modules\npm-registry-client\lib\get.js:142:7)
npm ERR!     at C:\Program Files (x86)\nodejs\node_modules\npm\node_modules\graceful-fs\polyfills.js:133:7
npm ERR!     at Object.oncomplete (fs.js:107:15)
npm ERR! If you need help, you may report this log at:
npm ERR!     <http://github.com/isaacs/npm/issues>
npm ERR! or email it to:
npm ERR!     <npm-@googlegroups.com>

npm ERR! System Windows_NT 6.1.7601
npm ERR! command "C:\\Program Files (x86)\\nodejs\\\\node.exe" "C:\\Program Files (x86)\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "instal
l" "karma-typescript-preprocessor"
npm ERR! cwd C:\Users\Me\WebstormProjects\Core
npm ERR! node -v v0.10.21
npm ERR! npm -v 1.3.11
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR!     C:\Users\Me\WebstormProjects\Core\npm-debug.log
npm ERR! not ok code 0

C:\Users\Me\WebstormProjects\Core>

我已将依赖项添加到package.json

"dependencies": {
        "express": "3.4.7",
        "ejs": "*",
        "less-middleware": "*",
        "formidable": "1.0.x",
        "socket.io": "0.9.x",
        "karma-typescript-preprocessor": "~0.1"
    }

我正在尝试在项目目录中安装模块。如果我尝试在Project目录外安装,模块就会安装,但是karma没有看到它。这是它抛出的错误:

INFO [karma]: Karma v0.10.9 server started at http://localhost:9876/
INFO [launcher]: Starting browser Chrome
WARN [preprocess]: Can not load "typescript", it is not registered!
  Perhaps you are missing some plugin?
INFO [Chrome 31.0.1650 (Windows 7)]: Connected on socket tyVcKoZygd-TRPnrm_WW
INFO [Chrome 31.0.1650 (Windows 7)]: Connected on socket o5hgQaj7f4B8-Ovfm_WX
INFO [Chrome 31.0.1650 (Windows 7)]: Connected on socket fvjPXprGmKQxWHROm_WY
Chrome 31.0.1650 (Windows 7) ERROR
        Uncaught SyntaxError: Unexpected reserved word
        at C:/Users/Anjan/WebstormProjects/Core/TsUnit/StartTest.ts:8
Chrome 31.0.1650 (Windows 7) ERROR
        Uncaught SyntaxError: Unexpected reserved word
        at C:/Users/Anjan/WebstormProjects/Core/TsUnit/StartTest.ts:8
Chrome 31.0.1650 (Windows 7) ERROR
        Uncaught SyntaxError: Unexpected reserved word
        at C:/Users/Anjan/WebstormProjects/Core/TsUnit/StartTest.ts:8
Chrome 31.0.1650 (Windows 7) ERROR
        Uncaught SyntaxError: Unexpected token :
Chrome 31.0.1650 (Windows 7): Executed 0 of 0 ERROR (0.363 secs / 0 secs)
Chrome 31.0.1650 (Windows 7): Executed 0 of 0 ERROR (1.162 secs / 0 secs)
Chrome 31.0.1650 (Windows 7): Executed 0 of 0 ERROR (0.643 secs / 0 secs)

1 个答案:

答案 0 :(得分:1)

"karma-typescript-preprocessor": "~0.1"无效。试试"karma-typescript-preprocessor": "0.0.6"

运行npm info karma-typescript-preprocessor以查找可用的版本。