๋ฌธ์ ์ ๋ํ ์ค๋ช ๋ฐ ์ฌํ ๋จ๊ณ:
์นํฉ ๊ตฌ์ฑ ์ถ๊ฐ:
resolve: {
alias: {
vue$: 'vue/dist/vue.esm.js',
moment: 'moment/src/moment'
}
}
<script>
import moment from 'moment'
moment.locale('zh-cn'); // pack error
</script>
์ฌ์ฉ๋ ๋ชจ๋ ๋ณ์์ ๊ฐ์ ํฌํจํ์ญ์์ค.
ํ๊ฒฝ:
OSX Node.js 8.4.0
ํนํ IOT ์ ํ๋ฆฌ์ผ์ด์ ๊ณผ ๊ฐ์ ๋น์ ์์ ์ธ ํ๊ฒฝ์ด ์๋ ๊ฒฝ์ฐ ๋ธ๋ผ์ฐ์ ์ OS๊ฐ ๋ชจ๋ ์ค์ํฉ๋๋ค.
๋์์ด ๋ ์ ์๋ ๊ธฐํ ์ ๋ณด:
๋ฌธ์ ๋ฅผ ๋ณด๊ณ ํ๋ ๊ฒฝ์ฐ ์ฌ์ฉ ์ค์ธ ํ๊ฒฝ์์ ๋ค์ ์ฝ๋๋ฅผ ์คํํ๊ณ ์ถ๋ ฅ์ ํฌํจํ์ญ์์ค.
console.log( (new Date()).toString())
console.log((new Date()).toLocaleString())
console.log( (new Date()).getTimezoneOffset())
console.log( navigator.userAgent)
console.log(moment.version)
console.log( (new Date()).toString())
Thu Aug 17 2017 17:09:27 GMT+0800 (CST)
console.log((new Date()).toLocaleString())
2017-8-17 17:09:27
console.log( (new Date()).getTimezoneOffset())
-480
console.log( navigator.userAgent)
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3178.0 Safari/537.36
console.log(moment.version)
2.18.1
๊ทํ์ ๋ฌธ์ ๊ฐ ์๊ฐ์ ๊ณ ๋ฆฝ๋์ด ์๋์ง ํ์ธํ์ญ์์ค.
WARNING in ./node_modules/moment/src/lib/locale/locales.js
Module not found: Error: Can't resolve './locale' in '/Users/willin/Documents/w2fs/coding-task/node_modules/moment/src/lib/locale'
@ ./node_modules/moment/src/lib/locale/locales.js 55:12-39
@ ./node_modules/moment/src/lib/locale/locale.js
@ ./node_modules/moment/src/moment.js
@ ./src/component/moment/index.js
@ ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib/selector.js?type=script&index=0!./src/router/timeline/tasks.vue
@ ./src/router/timeline/tasks.vue
@ ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib/selector.js?type=script&index=0!./src/router/timeline/timeline.vue
@ ./src/router/timeline/timeline.vue
@ ./src/router/timeline/index.js
@ ./src/router/index.js
@ ./src/main.js
@ multi (webpack)-dev-server/client?http://localhost:3993 webpack/hot/dev-server ./src/main.js
์ด๊ฒ์ #4042์์ ์์ ๋์์ผ๋ฉฐ ๋ค์ ๋ฆด๋ฆฌ์ค์์๋ ๊ด์ฐฎ์ ๊ฒ์
๋๋ค. ๊ทธ ๋์ ์ด ๋ฌธ์ ์ ๋ํ ๊ฐ์ฅ ์ ๋ขฐํ ์ ์๋ ํด๊ฒฐ ๋ฐฉ๋ฒ์ node_modules/moment ๋๋ ํ ๋ฆฌ์์ require('./locale/' + name)
๋ฅผ require('moment/locale/' + name)
๋ก ์๋์ผ๋ก ๋ณ๊ฒฝํ๋ ๊ฒ์
๋๋ค.
์ด ์์ ์ฌํญ์ด ์์ง ๋ฆด๋ฆฌ์ค์ ํฌํจ๋์ง ์์์์ ๋ณ๊ฒฝ ๋ก๊ทธ ํ์ด์ง์์ ํ์ธํ์ต๋๋ค.
webpack 3.6.0 + moment 2.19.0์๋ ์ฌ์ ํ ๋ฌธ์ ๊ฐ ์์ต๋๋ค.
์ต์ ๋ฆด๋ฆฌ์ค์์๋ ๋ฌธ์ ๊ฐ ํด๊ฒฐ๋์ง ์์ ๊ฒ ๊ฐ์ต๋๋ค .....
๋ฌธ์ ๊ฐ ์๋ ๊ฒ ๊ฐ์ต๋๋ค.
๊ฐ์ ๋ฌธ์ ๊ฐ ์์ต๋๋ค.
4๋์ ์ปดํจํฐ์์ ์์
ํ๋ ํ๋ก์ ํธ๊ฐ ์์ต๋๋ค. ์ค์ ํ๋ ค๋ ๋ค๋ฅธ ์ปดํจํฐ์์ ์ค๋ช
ํ ๊ฒ๊ณผ ๋์ผํ ์ค๋ฅ๊ฐ ๋ฐ์ํฉ๋๋ค.
Webpack(2.2.1) ๋ฐ Moment(2.15.1) ๋ฒ์ ์ ์ด๋์์๋ ๋์ผํฉ๋๋ค. ๋
ธ๋/Npm ์ ์ฌ/๋์ผ.
๊ฐ์ฅ ์ ์ฉํ ๋๊ธ
webpack 3.6.0 + moment 2.19.0์๋ ์ฌ์ ํ ๋ฌธ์ ๊ฐ ์์ต๋๋ค.
์ต์ ๋ฆด๋ฆฌ์ค์์๋ ๋ฌธ์ ๊ฐ ํด๊ฒฐ๋์ง ์์ ๊ฒ ๊ฐ์ต๋๋ค .....