错误:运行“bower install”时找不到模块'js-yaml'

时间:2022-10-13 19:43:46

I am walking through basic set up of an AngularJS application (Just getting started) and am currently trying to install Bower components for the application.

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

When I run bower install from the terminal, I get the following error:

当我从终端运行bower安装时,我收到以下错误:

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)

I haven’t specified js-yaml module anywhere in my scripts (as far as I am aware), so not sure where this dependency is coming from.

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

I have tried deleting the node_modules folder, clearing the npm cache, including js-yaml within the package.json file then re-running npm install, but I get the same error when running bower install

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

If it helps, my bower.json and package.json files are shown below:

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

Bower.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

的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"
  }
}

I am using WebStorm 10.0.4 (empty project as the starting point).

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

Has anyone come across this or a similar issue and possible point me in the right direction on how to resolve the issue?

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

2 个解决方案

#1


2  

Running sudo npm install -g js-yaml first should get you in the right direction.

首先运行sudo npm install -g js-yaml会让你朝着正确的方向前进。

#2


1  

My guess is that its not related to your application but bower is broken. Try reinstall it:

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

$ npm uninstall bower

And then reinstall it like this:

然后像这样重新安装:

$ npm install -g bower

That solved it for me.

这解决了我。

#1


2  

Running sudo npm install -g js-yaml first should get you in the right direction.

首先运行sudo npm install -g js-yaml会让你朝着正确的方向前进。

#2


1  

My guess is that its not related to your application but bower is broken. Try reinstall it:

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

$ npm uninstall bower

And then reinstall it like this:

然后像这样重新安装:

$ npm install -g bower

That solved it for me.

这解决了我。