easy-team / egg-vue-webpack-boilerplate

Egg Vue Server Side Render (SSR) / Client Side Render (CSR)
https://easyjs.cn/egg-vue
MIT License
1.36k stars 248 forks source link

Could not find a declaration file for module 'lodash-id'. #149

Closed yrj-essential closed 4 years ago

yrj-essential commented 4 years ago

Framework: egg.js

const lodashid = require('lodash-id'); In this way, lodash-id is introduced to provide a unique id, but the module or declaration file cannot be found. What should I do? image

I have tried the following:

  1. Create a shims-lodashid.d.ts under the root directory and declare the module. declare module'lodash-id'; Although there is no prompt that the module cannot be found, lodashid has not been added successfully.

  2. Change the import address to an absolute address: const lodashid = require('E:/nodeStudy/egg-weibo/node_modules/lodash-id/src/index.js'); Still prompted that the module could not be found.

  3. Create tsconfig.json under the root directory and set "noImplicitAny" to false. It didn't work either.


框架:egg.js const lodashid = require('lodash-id'); 这样引入lodash-id来提供唯一id,但是找不到模块或申明文件,该如何处理呢? image

我做了以下尝试:

  1. 在根文件下创建一个shims-lodashid.d.ts,并申明模块。 declare module 'lodash-id'; 虽然没有提示找不到模块了,但是lodashid并没有添加成功。

  2. 将引入地址改为绝对地址: const lodashid = require('E:/nodeStudy/egg-weibo/node_modules/lodash-id/src/index.js'); 仍然提示找不到模块。

  3. 在根目录下创建tsconfig.json,并将“noImplicitAny”设为false。也没有用。

yrj-essential commented 4 years ago

The reason why there is no auto increment ID is that “push” method is used to insert data: this.get(collectionName).push(JSON).write(); after useing “insert ” method, auto increment ID is added. this.get(collectionName). Insert (JSON). Write ()

没有自增id的原因是,插入数据时使用的是push方法: this.get(collectionName).push(json).write(); 用insert方法后,能生成自增id了。 this.get(collectionName).insert(json).write();

hubcarl commented 4 years ago

create d.ts file,

declare module 'lodash-id'
yrj-essential commented 4 years ago

create d.ts file,

declare module 'lodash-id'

Thanks for your reply.