找不到模块' loadash'

时间:2018-03-31 16:36:16

标签: node.js mongodb graphql npm-start express-graphql

执行命令时出现以下错误:npm start

Cannot find module 'loadash'
    at Function.Module._resolveFilename (module.js:538:15)
    at Function.Module._load (module.js:468:25)
    at Module.require (module.js:587:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (<Path...>/data/dbConnector.js:3:1)
    at Module._compile (module.js:643:30)
    at loader (<Path...>\node_modules\babel-register\lib\node.js:144:5)
    at Object.require.extensions.(anonymous function) [as .js] (<Path...>\node_modules\babel-register\lib\node.js:154:7)
    at Module.load (module.js:556:32)
    at tryModuleLoad (module.js:499:12)
    at Function.Module._load (module.js:491:3)
    at Module.require (module.js:587:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (<Path...>/data/resolvers.js:2:1)
    at Module._compile (module.js:643:30)
    at loader (<Path...>\node_modules\babel-register\lib\node.js:144:5)
    at Object.require.extensions.(anonymous function) [as .js] (<Path...>\node_modules\babel-register\lib\node.js:154:7)
    at Module.load (module.js:556:32)
    at tryModuleLoad (module.js:499:12)
    at Function.Module._load (module.js:491:3)
    at Module.require (module.js:587:17)
    at require (internal/module.js:11:18)
[nodemon] app crashed - waiting for file changes before starting...

package.json文件:

{
  "name": "essentials",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "start": "nodemon ./index.js --exec babel-node -e js"
  },
  "author": "test",
  "license": "ISC",
  "dependencies": {
    "casual": "^1.5.19",
    "express": "^4.16.3",
    "express-graphql": "^0.6.12",
    "graphql": "^0.13.2",
    "graphql-tools": "^2.23.1",
    "loadash": "^1.0.0",
    "mongoose": "^5.0.12",
    "nodemon": "^1.17.2",
    "sequelize": "^4.37.5",
    "sqlite3": "^4.0.0"
  },
  "devDependencies": {
    "babel-cli": "^6.26.0",
    "babel-preset-env": "^1.6.1",
    "babel-preset-stage-0": "^6.24.1"
  }
}

我按照以下链接但仍然没有一个为我工作。

https://stackoverflow.com/questions/27431187/cannot-find-module-lodash

https://stackoverflow.com/questions/27431187/cannot-find-module-lodash/36618374

另外,我看到以下警告信息:

加载参考时遇到问题&#39; https://schemastore.azurewebsites.net/schemas/json/package.json&#39;:无法从https://schemastore.azurewebsites.net/schemas/json/package.json加载架构&#39;:无法连接到https://schemastore.azurewebsites.net/schemas/json/package.json。错误:证书链中的自签名证书

有人可以帮我解决这个问题吗?

1 个答案:

答案 0 :(得分:4)

包名称应为lodash,而不是loadash

packages.json中更正后,您需要执行npm install