Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

使用react-intl,编译小程序不通过 #1400

Closed
suuzee opened this issue Dec 6, 2018 · 4 comments
Closed

使用react-intl,编译小程序不通过 #1400

suuzee opened this issue Dec 6, 2018 · 4 comments
Labels
question Further information is requested

Comments

@suuzee
Copy link

suuzee commented Dec 6, 2018

问题描述
使用react-intl,编译小程序不通过

复现步骤

  1. Taro项目中引入react-intl
  2. 执行npm run dev:weapp

期望行为
编译通过,react-intl绝对路径引的包从node_modules里面找,而不是从相对位置找。

报错信息
react-intl源码是这样的:

// ...
var allLocaleData = _interopDefault(require('../locale-data/index.js'));
var IntlMessageFormat = _interopDefault(require('intl-messageformat'));
var IntlRelativeFormat = _interopDefault(require('intl-relativeformat'));
var PropTypes = _interopDefault(require('prop-types'));
var React = require('react');
var React__default = _interopDefault(React);
var hoistNonReactStatics = _interopDefault(require('hoist-non-react-statics'));
var invariant = _interopDefault(require('invariant'));
var memoizeIntlConstructor = _interopDefault(require('intl-format-cache'));

// ...
{ Error: ENOENT: no such file or directory, open '/Users/test/practices/taro-demo/node_modules/react-intl/lib/intl-format-cache'
    at Object.fs.openSync (fs.js:646:18)
    at Object.fs.readFileSync (fs.js:551:33)
    at buildSingleComponent (/Users/test/.nvm/versions/node/v8.14.0/lib/node_modules/@tarojs/cli/src/weapp.js:1631:31)
    at buildSingleComponent (/Users/test/.nvm/versions/node/v8.14.0/lib/node_modules/@tarojs/cli/src/weapp.js:1667:20)
    at Promise.all.componentPathList.map.componentObj (/Users/test/.nvm/versions/node/v8.14.0/lib/node_modules/@tarojs/cli/src/weapp.js:1574:60)
    at Array.map (<anonymous>)
    at buildDepComponents (/Users/test/.nvm/versions/node/v8.14.0/lib/node_modules/@tarojs/cli/src/weapp.js:1574:40)
    at buildSinglePage (/Users/test/.nvm/versions/node/v8.14.0/lib/node_modules/@tarojs/cli/src/weapp.js:1323:40)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:189:7)
  errno: -2,
  code: 'ENOENT',
  syscall: 'open',
  path: '/Users/test/practices/taro-demo/node_modules/react-intl/lib/intl-format-cache' }

系统信息

  • 操作系统: macOS 10.14
  • Taro 版本: v1.2.0.beta9
  • Node.js: 版本 v8.14
  • 报错平台: weapp

补充信息
感觉问题可能出在这,但是理解不深,不敢猜测

// @tarojs/cli/src/util/index.js 335
exports.resolveScriptPath = function (p) {
  let realPath = p
  const SCRIPT_EXT = exports.JS_EXT.concat(exports.TS_EXT)
  for (let i = 0; i < SCRIPT_EXT.length; i++) {
    const item = SCRIPT_EXT[i]

    if (fs.existsSync(`${p}${item}`)) {
      return `${p}${item}`
    }
    if (fs.existsSync(`${p}${path.sep}index${item}`)) {
      return `${p}${path.sep}index${item}`
    }
  }
  return realPath
}
@taro-bot
Copy link

taro-bot bot commented Dec 6, 2018

欢迎提交 Issue~

如果你提交的是 bug 报告,请务必遵循 Issue 模板的规范,尽量用简洁的语言描述你的问题,最好能提供一个稳定简单的复现。🙏🙏🙏

如果你的信息提供过于模糊或不足,或者已经其他 issue 已经存在相关内容,你的 issue 有可能会被关闭。

Good luck and happy coding~

@suuzee suuzee changed the title 使用react-intl,编译小程序不通过 使用react-intl,编译小程序不通过 Dec 6, 2018
@luckyadam
Copy link
Member

react 的组件用不了

@luckyadam luckyadam added question Further information is requested answered labels Dec 6, 2018
@taro-bot taro-bot bot added the to be closed label Dec 6, 2018
@taro-bot
Copy link

taro-bot bot commented Dec 6, 2018

Hello~

您的问题楼上已经有了确切的回答,如果没有更多的问题这个 issue 将在 15 天后被自动关闭。

如果您在这 15 天中更新更多信息自动关闭的流程会自动取消,如有其他问题也可以发起新的 Issue。

Good luck and happy coding~

@joyran
Copy link

joyran commented Dec 29, 2018

@suuzee hello, 请问问题如何解决的,谢谢

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants