找不到模块“lodash” [英] cannot find module "lodash"

查看:1503
本文介绍了找不到模块“lodash”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

今天,我试着更多地了解Google Web Starter Kit,所以我遵循这些说明,经过很多争论和问题之后,我试图启动一个本地服务器(我们要看的第一个任务是: $ gulp serve 。)并收到此错误:

\gwsk> gulp serve

 错误:无法在Function.Module._resolveFilename(module.js:338:15)处找到模块'lodash'

在Function.Module._load (module.js:280:25)
at Module.require(module.js:364:17)
at require(module.js:380:17)
at Object。<匿名> (C:\gwsk\\\
ode_modules\browser-sync\\\
ode_modules\portsc
anner-plus\lib\index.js:3:9)
在Module._compile(module .js:456:26)
在Object.Module._extensions..js(module.js:474:10)
在Module.load(module.js:356:32)
(Module.js:312:12)
at Module.require(module.js:364:17)
at require(module.js:380:17)$ b $在Function.Module._load b在Object。< anonymous> (C:\gwsk\\\
ode_modules\browser-sync\lib\utils.js:6:19)

老实说,我完全迷失在这里,所以任何帮助都非常受欢迎。我是新来的node.js,吞噬,我只是想让它尝试GWSK,但变成头痛:(...我是一个网页设计师,而不是开发人员....


<请确保在所需的文件夹中安装lodash,这可能是您的C:\gwsk目录。

如果该文件夹有一个package.json文件,最好在安装命令后加上--save。

  $ npm install lodash --save 

package.json文件包含有关该项目的信息,但要保留它很容易保存你的项目依赖项。



save命令会将安装的模块添加到项目依赖项中。



如果package.json文件存在,并且它包含lodash依赖项,则可以尝试删除node_modules文件夹并运行以下命令:

  $ npm cache clean 
$ npm install

第一个命令将清理NP (只是可以肯定)
第二个命令会安装项目的所有(缺失)依赖项。



希望这有助于你理解节点包经理多一点。


Today I tried to learn more about Google Web Starter Kit so I followed these instructions and after a lot of fight and problem I just tried to start a local server (the first task we’ll look at is: $ gulp serve.) and received this error:

C:\gwsk>gulp serve

Error: Cannot find module 'lodash'
    at Function.Module._resolveFilename (module.js:338:15)
    at Function.Module._load (module.js:280:25)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at Object.<anonymous> (C:\gwsk\node_modules\browser-sync\node_modules\portsc
anner-plus\lib\index.js:3:9)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at Object.<anonymous> (C:\gwsk\node_modules\browser-sync\lib\utils.js:6:19)

Honestly I'm completely lost here, so any help is pretty welcome. I'm new to node.js, to gulp, I just wanted it to try GWSK but turn into a headache :(... I'm a web designer not developer....

解决方案

Be sure to install lodash in the required folder. This is probably your C:\gwsk directory.

If that folder has a package.json file, it is also best to add --save behind the install command.

$ npm install lodash --save

The package.json file holds information about the project, but to keep it simple, it holds your project dependencies.

The save command will add the installed module to the project dependencies.

If the package.json file exists, and if it contains the lodash dependency you could try to remove the node_modules folder and run following command:

$ npm cache clean    
$ npm install

The first command will clean the npm cache. (just to be sure) The second command will install all (missing) dependencies of the project.

Hope this helps you understand the node package manager a little bit more.

这篇关于找不到模块“lodash”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆