首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >由于导入解析错误,世博建设失败

由于导入解析错误,世博建设失败
EN

Stack Overflow用户
提问于 2019-10-22 09:43:50
回答 2查看 872关注 0票数 0

用类型记录获取分辨率错误

src/常数/Config.ts

代码语言:javascript
复制
export const Config = {
  auth0: {
    client_id: 'xxxx',
    connection: 'xxxx',
    url: 'https://xxxx.eu.auth0.com',
  },
};
代码语言:javascript
复制
import {Config} from '@src/constants/Config';

使用expo on react本机,使faild生成脚本

代码语言:javascript
复制
Unable to resolve "@src/constants/Config" from "src/containers/layouts/auth/signUp2/signUp2.component.tsx"
Failed building JavaScript bundle.

尝试用tsc构建,构建很好,但是运行世博启动会导致错误。

tsconfig

代码语言:javascript
复制
{
  "compilerOptions": {
    "baseUrl": "./",
    "outDir": "./dist/tsc-out",
    "allowSyntheticDefaultImports": true,
    "esModuleInterop": true,
    "moduleResolution": "node",
    "skipLibCheck": true,
    "sourceMap": true,
    "resolveJsonModule": true,
    "experimentalDecorators": true,
    "jsx": "react-native",
    "module": "es2015",
    "target": "es2017",
    "lib": [
      "es2015",
      "es2016"
    ],
    "paths": {
      "@src/*": ["./src/*"],
      "@kitten/*": ["./node_modules/react-native-ui-kitten/*"]
    },
    "typeRoots": [
      "./node_modules/@types"
    ]
  },
  "include": [
    "./src/**/*"
  ],
  "exclude": [
    "./node_modules"
  ]
}

巴贝尔

代码语言:javascript
复制
const path = require('path');
const Config = require('./config');

// FIXME: Resolve `transform[stderr]: Could not resolve` command-line warnings.
// FIXME: Reproducible when starting with clearing cache (npm start -- -c)
//
// TODO: Framework path aliasing even not needed here. Replace?
// TODO: Replace nested package.json-s with aliases

const moduleResolverConfig = {
  root: path.resolve('./'),
  alias: {
    '@kitten/theme': path.resolve(Config.KITTEN_PATH, 'theme'),
    '@kitten/ui': path.resolve(Config.KITTEN_PATH, 'ui'),
    '@eva-design/eva': path.resolve(Config.MAPPING_PATH),
    '@eva-design/processor': path.resolve(Config.PROCESSOR_PATH),
  },
};

module.exports = function (api) {
  api.cache(true);

  const presets = [
    'babel-preset-expo',
  ];

  const plugins = [
    ['module-resolver', moduleResolverConfig],
  ];

  return { presets, plugins };
};
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2019-10-25 10:02:53

最终起作用的是设置babel配置和tsconfig。

票数 0
EN

Stack Overflow用户

发布于 2019-10-25 06:57:38

我在这里看到Kitten Tricks应用程序配置文件。拥有别名的意义只在于为这个应用程序创建一个开发环境,因为我们有时会使用它来检查本机ui-kitten更改。如果您只在生产模式中使用它,则可以删除dev.env.js文件夹中的./config

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/58501433

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档