错误:找不到模块' js-yaml'当跑步" bower install"

时间:2015-11-25 23:34:43

标签: angularjs node.js npm bower bower-install

我正在介绍AngularJS应用程序的基本设置(刚入门),目前正在尝试为应用程序安装Bower组件。

当我从终端运行bower install时,出现以下错误:

Error: Cannot find module 'js-yaml'
    at Function.Module._resolveFilename (module.js:337:15)
    at Function.Module._load (module.js:287:25)
    at Module.require (module.js:366:17)
    at require (module.js:385:17)
    at Object.<anonymous> (Path\bower\node_modules\configstore\index.js:9:12)
    at Module._compile (module.js:425:26)
    at Object.Module._extensions..js (module.js:432:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:311:12)
    at Module.require (module.js:366:17)
    at require (module.js:385:17)

我没有在我的脚本中的任何地方指定js-yaml模块(据我所知),所以不确定这种依赖来自何处。

我尝试删除node_modules文件夹,清除npm缓存,包括js-yaml文件中的package.json,然后重新运行npm install,但运行bower install时出现同样的错误

如果有帮助,我的bower.jsonpackage.json文件如下所示:

Bower.json

{
  "name": "starter-node-angular",
  "version": "1.0.0",
  "dependencies": {
    "bootstrap": "latest",
    "font-awesome": "latest",
    "animate.css": "latest",
    "angular": "latest",
    "angular-route": "latest"
  }
}

的package.json

{
  "name": "starter-node-angular",
  "main": "server.js",
  "dependencies": {
    "express" : "~4.5.1",
    "mongoose" : "~3.8.0",
    "body-parser" : "~1.4.2",
    "method-override" : "~2.0.2",
    "js-yaml" : "latest"
  }
}

我正在使用WebStorm 10.0.4(空项目作为起点)。

有没有人遇到过这个或类似的问题,并且可能指出我如何解决问题的正确方向?

2 个答案:

答案 0 :(得分:2)

首先运行/* * arraySize : array size to use for the test * min : min jump in the array * max : max jump in the array */ void testJumps(int arraySize, int min, int max){ static int counter = 0; std::cout << "-----------Test " << counter << "------------" << std::endl; std::cout << "Array size : " << arraySize << " Minimum Jump : " << min << " Max Jump" << max << std::endl; //Create vector with random numbers std::vector<int> vecNumbers(arraySize, 0); for(unsigned int i = 0; i < vecNumbers.size(); i++) vecNumbers[i] = rand() % max + min; //Value of first function int iVersion1 = jump1(vecNumbers); //Second fucntion int iVersion2 = jump2(vecNumbers); assert(iVersion1 == iVersion2); std::cout << "Test " << counter << " succeeded" << std::endl; std::cout << "-----------------------" << std::endl; counter++; } int main() { //Two test testJumps(10, 1, 100); testJumps(20, 10, 200); //You can even make a loop of test //... } 会让你朝着正确的方向前进。

答案 1 :(得分:1)

我的猜测是它与您的应用程序无关,但是打包机坏了。尝试重新安装:

$ npm uninstall bower

然后像这样重新安装:

$ npm install -g bower

这解决了我。