无法通过Node.jsfind模块“lodash.curry”

我正在从Frisby教授的大部分“充足指南”的 Currying主题着手,在实现浏览器无法运行require()之后,我尝试通过npm安装lodash。 我一直在这里search使用类似的解决scheme,但不工作,我想使其在本地服务器上运行节点或使用script ,下面仍然是相同的结果,也ramda

 Error: Cannot find module 'lodash.curry' at Function.Module._resolveFilename (module.js:327:15) at Function.Module._load (module.js:278:25) at Module.require (module.js:355:17) at require (internal/module.js:13:17) at Object.<anonymous> (/Users/hueke32/Desktop/lodash_test/lodashTest.js:1:13) at Module._compile (module.js:399:26) at Object.Module._extensions..js (module.js:406:10) at Module.load (module.js:345:32) at Function.Module._load (module.js:302:12) at Function.Module.runMain (module.js:431:10) 

的package.json

 { "name": "lodash_test", "version": "1.0.0", "description": "", "main": "lodashTest.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, "author": "", "license": "ISC", "dependencies": { "browser-sync": "^2.11.0", "lodash": "^3.10.1" } } 

lodashTest.js

 var curry = require('lodash.curry'); var match = curry(function(what, str) { return str.match(what); }); var replace = curry(function(what, replacement, str) { return str.replace(what, replacement); }); var filter = curry(function(f, ary) { return ary.filter(f); }); var map = curry(function(f, ary) { return ary.map(f); }); match(/\s+/g, "hello world"); match(/\s+/g)("hello world"); var hasSpaces = match(/\s+/g); hasSpaces("hello world"); hasSpaces("spaceless"); filter(hasSpaces, ["tori_spelling", "tori amos"]); var findSpaces = filter(hasSpaces); findSpaces(["tori_spelling", "tori amos"]); var noVowels = replace(/[aeiou]/ig); var censored = noVowels("*"); censored("Chocolate Rain"); 

的index.html

 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> <script src="lodashTest.js"></script> </head> <body> </body> </html> 

lodash.curry不是一个模块。 lodashcurry作为成员的模块。 你应该像下面那样纠正你的要求。

var curry = require('lodash').curry;