-
Notifications
You must be signed in to change notification settings - Fork 202
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
34Uncaught (in promise) TypeError: moment is not a function(…) #116
Comments
Can you past a link to your code? It seems like you aren't passing |
Same problem here. |
I'm having the same issue. Any timeline for when this could get fixed? |
@skratchdot I'm having the same issue, how to fix it? |
I'm having the same issue. And solved by calling moment.min.js file before daterangepicker.js in the end of html body. |
Same issue here. I made sure that I include moment.js dependency before react-bootstrap-daterangepicker one. I am using webpack for building the app, and getting the same error as posted. All of my other moment.js applications are working as expected. |
Same. Try to init daterange into my Vue component. Problem starts from migration (browserify to webpack) on browserify + vueify moment works fine |
Not sure this isn't yet fixed but - Load moment.min.js before daterangepicker.js |
Thanks @ciolansteen ^^ this solved it for me! |
I faced the same issue and I use webpack in my project. Little bit of digging into bootstrap-datepicker code helped me solve this. Add this to 'modules' in webpack config, where all the rules are rules: [
{
test: require.resolve('path_to_node_modules/bootstrap-daterangepicker/daterangepicker.js'),
use: 'imports-loader?define=>false',
},
] Now we need to expose our moment.js module on window to bypass the ternary condition and avoid getting the moment module from require.js new webpack.ProvidePlugin({
'window.moment': ['moment', 'default'],
}), PS: |
that solved my problem |
closing this due to inactivity. please re-open if this is still an issue in v6.0.0 or greater |
yes as there are moment() func in daterangepicker.js file..so we need to call the moment.min.js file before daterangepicker.js. |
@skratchdot am facing this same issue. |
Laravel: v11, How to fix 'Uncaught (in promise) TypeError: moment is not a function with datarangepicker plugin'npm install jquery
npm install daterangepicker
npm install moment add below code in app.jsapp.js path --> import $ from "jquery";
window.jQuery = window.$ = $;
import * as moment from 'moment';
import 'daterangepicker'; in @import 'daterangepicker/daterangepicker.css'; vite config filevite.config.js --> import {defineConfig} from 'vite';
import laravel from 'laravel-vite-plugin';
import path from 'path';
export default defineConfig({
server: {
watch: {
usePolling: true,
ignored: [
'**/node_modules/**',
'**/vendor/**',
],
},
},
plugins: [
laravel({
input: [
'resources/css/app.css',
'resources/js/app.js',
],
refresh: true,
}),
],
resolve: {
alias: {
'~bootstrap': path.resolve(__dirname, 'node_modules/bootstrap'),
'$': 'jQuery',
'moment': path.resolve(__dirname, 'node_modules/moment/moment'),
}
}
}); How to use.
<script type="module">
const initializeDateRangePicker = () => {
$('#monthly-date-range').daterangepicker({
opens: 'center',
locale: {
format: 'YYYY-MM-DD'
},
startDate: ---,
endDate: ---
});
initializeDateRangePicker();
</script> |
The text was updated successfully, but these errors were encountered: