Don't know if it is related to #4216 because I'm using Angular 4.4.4
and that is a React
issue, so I'm posting this as a separate issue.
I got the following error after the update:
__WEBPACK_IMPORTED_MODULE_2_moment__ is not a function
I'm using the following moment
packages
"moment": "2.19.0",
"@types/moment": "2.13.0",
The code where I get the error is quite simple:
import * as moment from 'moment';
...
if (moment().year() !== this.mainData.activeYear)
...
+1 - Same issue with Angular 4
Same here. Not using Angular or React. This is my webpack error:
WARNING in ./~/moment/src/lib/locale/locales.js
Module not found: Error: Can't resolve './locale' in '/data/jenkins/workspace/project/node_modules/moment/src/lib/locale'
./~/moment/src/lib/locale/locales.js 65:16-60
./~/moment/src/lib/locale/locale.js
./~/moment/src/moment.js
./script.js
Same problem with vuejs and webpack.
Same here with webpack, although the issue is triggered by moment-timezone. We changed the dependency from "moment": "^2.18.1"
to "moment": "~2.18.1"
same problem when moment upgrade to version 2.19.0
WARNING in ./~/[email protected]@moment/src/lib/locale/locales.js
Module not found: Error: Can't resolve './locale' in '/Users/XXX/code/gitlab/web-editor/node_modules/[email protected]@moment/src/lib/locale'
@ ./~/[email protected]@moment/src/lib/locale/locales.js 65:16-60
@ ./~/[email protected]@moment/src/lib/locale/locale.js
@ ./~/[email protected]@moment/src/moment.js
@ ./~/[email protected]@antd/lib/calendar/index.js
@ ./~/[email protected]@antd/lib/index.js
@ dll lib
Same problem here with 2.19.0
Same issue on this 2.19.0
version
This version ( 2.19.0 must be fixed )
for the 'moment' ahahah, install the 2.18.1
"moment": "~2.18.1"
Same issue here 😢 We'll downgrade back to 2.18 until this is resolved.
Same problem here...
react webpack error
WARNING in ./node_modules/moment/src/lib/locale/locales.js
Module not found: Error: Can't resolve './locale' in 'blahblahblah/node_modules/moment/src/lib/locale'
@ ./node_modules/moment/src/lib/locale/locales.js 65:16-60
@ ./node_modules/moment/src/lib/locale/locale.js
@ ./node_modules/moment/src/moment.js
@ ./src/client/components/ArticlesGrid/index.js
@ ./src/client/containers/StuffPage/index.js
@ ./src/client/routes.jsx
@ ./src/client/index.js
@ multi (webpack)-dev-server/client?http://0.0.0.0:8050 webpack/hot/dev-server babel-polyfill ./src/client/index.js
@mymtw - as a community, we don't allow swearing on the forms so your comment has been updated. Please refrain in the future.
Got this one after upgrading to 2.19...
node_modules/webpack/lib/IgnorePlugin.js:20
(!contextRegExp || contextRegExp.test(result.context))) {
^
TypeError: contextRegExp.test is not a function
And using ignore plugin to skip locales on my webpack config file:
new webpack.IgnorePlugin(/^\.\/locale$/, [/moment$/])
Locking the version of moment in package.json
will help:
"moment": "2.18.0"
However, if the latest moment version (2.19.0) is being pulled by your dependencies, the above won't work (run find ./node_modules/*/node_modules -iname moment
to check other versions of moment in your app)
You can instead use webpack externals:
+ externals: {
+ moment: 'moment',
+ },
<script src="https://momentjs.com/downloads/moment.min.js"></script>
Downgraded to ~2.18.0
which circumvents this for the time being.
Here is a reproduction step that works for me. I am assuming you have create-react-app
installed globally:
> create-react-app my-app
> cd my-app
> # Prove the app it working correctly
> npm run start
> npm install moment
Update src/app.js
with something like:
import '.App.css';
+ import moment from 'moment'
class App extends Component {
</p>
+<p>
+ Today is {moment().format()}
+</p>
</div>
Then
> npm run start
Expect website to load.
Actual, fails with a Error: Can't resolve './locale' error.
Extra context, works after doing
> npm install [email protected]
This is interesting. I just updated moment on my own code that I work on for my job, and started webpack. As far as I can tell I have the latest of all webpack dependencies (there are several, and I've only checked a few), and moment 2.19.0, and everything is fine.
I'll try this create-react-app path next.
This was not a very happy morning with this error!
Ditto on this error.
npm install --save [email protected]
This fixes the problem for time being. 2.19.0 was giving me same error about 2 hours back.
Downgraded to version 2.18.1 and it worked fine.
We can also corroborate this scenario.
2.19.0 broke our production build :(. Reverting back to 2.18.1 seems to be working fine.
Closing as a duplicate of #4216 - track there.
Most helpful comment
Same here. Not using Angular or React. This is my webpack error: