eslint提示 xxx should be listed in the project's dependencies

有时候手动安装了一个npm包A,npm包A里面包含了npm包B,这时候如果
import xxx from 'npm包B';

eslint会报错,提示 npm包B 不在 package.json 里面

 解决方法:在 eslintrc.js 增加配置

module.exports = {
  rules: {
    'import/no-extraneous-dependencies': [
      0,
      {
        devDependencies: true,
        peerDependencies: true
        // optionalDependencies: true,
        // bundledDependencies: true
      }
    ]
  }
};

你可能感兴趣的:(eslint提示 xxx should be listed in the project's dependencies)