如何在yarn中导入本地依赖

问题描述 投票:0回答:1

我有2个项目:

  • ProjectA:一个 Vue.js 前端项目
  • ProjectB:我想在项目 A 中用作库的 js 模块

我正确构建了 ProjectB,然后:

yarn link

我在ProjectA的

package.json
中添加了依赖项
"ProjectB":"1.0.0"
然后在ProjectA root
yarn link ProjectB

当我尝试导入 ProjectB 时:

import {Stuff} from 'ProjectB'
Vuejs 项目的构建失败并出现此错误(这似乎无关,但导入导致了它):

 ERROR  Failed to compile with 1 errors 
Module build failed (from ./node_modules/@vue/cli-plugin-eslint/node_modules/eslint-loader/index.js):
Error: No ESLint configuration found.
    at Config.getLocalConfigHierarchy (/nodejs/wrapper_project/vuejs_frontend/node_modules/eslint/lib/config.js:268:39)
    at Config.getConfigHierarchy (/nodejs/wrapper_project/vuejs_frontend/node_modules/eslint/lib/config.js:192:43)
    at Config.getConfigVector (/nodejs/wrapper_project/vuejs_frontend/node_modules/eslint/lib/config.js:299:21)
    at Config.getConfig (/nodejs/wrapper_project/vuejs_frontend/node_modules/eslint/lib/config.js:342:29)
    at processText (/nodejs/wrapper_project/vuejs_frontend/node_modules/eslint/lib/cli-engine.js:181:33)
    at CLIEngine.executeOnText (/nodejs/wrapper_project/vuejs_frontend/node_modules/eslint/lib/cli-engine.js:690:40)
    at lint (/nodejs/wrapper_project/vuejs_frontend/node_modules/@vue/cli-plugin-eslint/node_modules/eslint-loader/index.js:263:17)
    at transform (/nodejs/wrapper_project/vuejs_frontend/node_modules/@vue/cli-plugin-eslint/node_modules/eslint-loader/index.js:237:18)
    at /nodejs/wrapper_project/vuejs_frontend/node_modules/loader-fs-cache/index.js:127:18
    at ReadFileContext.callback (/nodejs/wrapper_project/vuejs_frontend/node_modules/loader-fs-cache/index.js:31:14)
    at FSReqWrap.readFileAfterOpen [as oncomplete] (fs.js:237:13)

You may use special comments to disable some warnings.
Use // eslint-disable-next-line to ignore the next line.
Use /* eslint-disable */ to ignore all warnings in a file. 

我错过了什么?

这些问题似乎相关:

node.js vue.js npm ecmascript-6 yarnpkg
1个回答
0
投票

Vue 对格式设置相当严格。

因此,诸如缺少 ESLint(ECMAScript linter)之类的东西将引发错误而不是良性警告。

我会按照错误提示进行操作,并向项目中添加一个基本的 ESLint 文件,或者添加这些注释之一以在该文件中禁用它。

© www.soinside.com 2019 - 2024. All rights reserved.