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

升级 2.1.0 后仍然会有 moment locales 找不到的问题 #3508

Closed
starbit opened this issue Oct 20, 2016 · 8 comments
Closed

升级 2.1.0 后仍然会有 moment locales 找不到的问题 #3508

starbit opened this issue Oct 20, 2016 · 8 comments

Comments

@starbit
Copy link

starbit commented Oct 20, 2016

环境:

  • antd 版本: 2.1.0
  • 操作系统及其版本: macOS Sierra
  • 没有安装 babel-plugin-import

报错:

WARNING in ./~/moment/src/lib/locale/locales.js
Module not found: Error: Can't resolve './locale' in '/project_path/node_modules/moment/src/lib/locale'
 @ ./~/moment/src/lib/locale/locales.js 54:12-39
 @ ./~/moment/src/lib/locale/locale.js
 @ ./~/moment/src/moment.js
 @ ./~/antd/lib/locale-provider/en_US.js
 @ ./app/containers/App/index.js
 @ ./app/routes/index.js
 @ ./app/app.js
 @ multi main

所有依赖:

"dependencies": {
    "antd": "2.1.0",
    "babel-polyfill": "6.13.0",
    "chalk": "1.1.3",
    "compression": "1.6.2",
    "cross-env": "2.0.1",
    "express": "4.14.0",
    "fontfaceobserver": "2.0.4",
    "i18next": "3.4.3",
    "immutable": "3.8.1",
    "intl": "1.2.4",
    "invariant": "2.2.1",
    "ip": "1.1.3",
    "lodash": "4.15.0",
    "minimist": "1.2.0",
    "querystring": "0.2.0",
    "react": "15.3.2",
    "react-collapse": "2.3.3",
    "react-dom": "15.3.2",
    "react-fa": "4.1.2",
    "react-height": "2.1.1",
    "react-helmet": "3.1.0",
    "react-i18next": "1.10.1",
    "react-intl": "2.1.5",
    "react-motion": "0.4.4",
    "react-redux": "4.4.5",
    "react-router": "2.8.0",
    "react-router-redux": "4.0.5",
    "react-router-scroll": "0.3.2",
    "redux": "3.6.0",
    "redux-immutable": "3.0.8",
    "redux-saga": "0.11.1",
    "reselect": "2.5.3",
    "sanitize.css": "4.1.0",
    "url": "0.11.0",
    "warning": "3.0.0",
    "whatwg-fetch": "1.0.0"
  },
  "devDependencies": {
    "babel-cli": "6.14.0",
    "babel-core": "6.14.0",
    "babel-eslint": "6.1.2",
    "babel-loader": "6.2.5",
    "babel-plugin-istanbul": "2.0.1",
    "babel-plugin-react-intl": "2.2.0",
    "babel-plugin-react-transform": "2.0.2",
    "babel-plugin-transform-react-constant-elements": "6.9.1",
    "babel-plugin-transform-react-inline-elements": "6.8.0",
    "babel-plugin-transform-react-remove-prop-types": "0.2.9",
    "babel-preset-es2015": "6.14.0",
    "babel-preset-react": "6.11.1",
    "babel-preset-react-hmre": "1.1.1",
    "babel-preset-stage-0": "6.5.0",
    "chai": "3.5.0",
    "chai-enzyme": "0.5.1",
    "cheerio": "0.20.0",
    "coveralls": "2.11.12",
    "css-loader": "0.25.0",
    "enzyme": "2.4.1",
    "eslint": "3.5.0",
    "eslint-config-airbnb": "11.1.0",
    "eslint-config-airbnb-base": "7.1.0",
    "eslint-import-resolver-webpack": "0.5.1",
    "eslint-plugin-import": "1.14.0",
    "eslint-plugin-jsx-a11y": "2.2.2",
    "eslint-plugin-react": "6.2.0",
    "eventsource-polyfill": "0.9.6",
    "expect": "1.20.2",
    "expect-jsx": "2.6.0",
    "exports-loader": "0.6.3",
    "extract-text-webpack-plugin": "2.0.0-beta.4",
    "file-loader": "0.9.0",
    "html-loader": "0.4.3",
    "html-webpack-plugin": "2.22.0",
    "image-webpack-loader": "2.0.0",
    "imports-loader": "0.6.5",
    "json-loader": "0.5.4",
    "karma": "1.3.0",
    "karma-chrome-launcher": "2.0.0",
    "karma-coverage": "1.1.1",
    "karma-firefox-launcher": "1.0.0",
    "karma-ie-launcher": "1.0.0",
    "karma-mocha": "1.1.1",
    "karma-mocha-reporter": "2.1.0",
    "karma-safari-launcher": "1.0.0",
    "karma-sourcemap-loader": "0.3.7",
    "karma-webpack": "1.8.0",
    "lint-staged": "3.0.1",
    "mocha": "3.0.2",
    "null-loader": "0.1.1",
    "offline-plugin": "3.4.2",
    "plop": "1.5.0",
    "postcss-cssnext": "2.8.0",
    "postcss-focus": "1.0.0",
    "postcss-loader": "0.13.0",
    "postcss-reporter": "1.4.1",
    "pre-commit": "1.1.3",
    "psi": "2.0.4",
    "rimraf": "2.5.4",
    "shelljs": "0.7.4",
    "sinon": "2.0.0-pre",
    "style-loader": "0.13.1",
    "stylelint": "7.2.0",
    "stylelint-config-standard": "13.0.0",
    "url-loader": "0.5.7",
    "webpack": "2.1.0-beta.22",
    "webpack-dev-middleware": "1.7.0",
    "webpack-hot-middleware": "2.12.2"
  }
@BANG88
Copy link
Member

BANG88 commented Oct 20, 2016

See moment/moment#1435

@afc163
Copy link
Member

afc163 commented Oct 20, 2016

#3204 (comment) 里解决了直接 import { xxx } from 'antd 又没有使用 babel-plugin-import 或 babel-plugin-antd 的问题。(因为会走 antd/dist/antd.js 这个文件)

楼主应该是直接 import xxx from 'antd/lib/xxx' 这么使用的,那么可以按照这个回复来解决。

@starbit
Copy link
Author

starbit commented Oct 20, 2016

Thanks @BANG88 !

I fixed it by aliasing 'moment' to 'moment/moment.js' in my webpack config (resolve: { alias: { moment: 'moment/moment.js' } }).

@starbit
Copy link
Author

starbit commented Oct 20, 2016

@afc163 我确实是通过 import { xxx } from 'antd' 来使用的呀~

@afc163
Copy link
Member

afc163 commented Oct 20, 2016

看看 locale-provider 是怎么调用的,你的信息里是直接走了 lib 目录的。

 @ ./~/moment/src/moment.js
 @ ./~/antd/lib/locale-provider/en_US.js
 @ ./app/containers/App/index.js

@starbit
Copy link
Author

starbit commented Oct 20, 2016

@afc163 好像找到问题了,为了在用户切换语言的时候也切换 antd 组件的语言,我在 ./app/containers/App/index.js 里面引入了 import enUS from 'antd/lib/locale-provider/en_US';

@afc163
Copy link
Member

afc163 commented Oct 20, 2016

Ok~

总之,根本原因还是 moment 的问题,webpack 的各种 hack 配置目前还是少不了。

@afc163 afc163 closed this as completed Oct 20, 2016
@lock
Copy link

lock bot commented May 3, 2018

This thread has been automatically locked because it has not had recent activity. Please open a new issue for related bugs and link to relevant comments in this thread.

@lock lock bot locked as resolved and limited conversation to collaborators May 3, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants