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

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

问题描述

今天我尝试了解有关 Google Web Starter Kit 的更多信息,因此我关注了 这些说明 经过大量的斗争和问题后,我只是尝试启动本地服务器(我们要查看的第一个任务是:$ gulp serve.) 并收到此错误:

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>一饮而尽

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
ode_modulesrowser-sync
ode_modulesportsc
anner-pluslibindex.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
ode_modulesrowser-synclibutils.js:6:19)

老实说,我完全迷失在这里,所以非常欢迎任何帮助.我是 node.js 的新手,对 gulp 来说,我只是想让它尝试 GWSK,但结果变得头疼:(...我是网页设计师而不是开发人员....

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

推荐答案

一定要在需要的文件夹中安装lodash.这可能是您的 C:gwsk 目录.

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

如果该文件夹有 package.json 文件,最好在 install 命令后面加上 --save.

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

$ npm install lodash --save

package.json 文件包含有关项目的信息,但为了简单起见,它包含您的项目依赖项.

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

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

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

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

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

第一个命令将清理 npm 缓存.(只是要确定)第二个命令将安装项目的所有(缺少的)依赖项.

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天全站免登陆