I am currently working on a Gridsome project (v0.7.23) where I have loaded the Bootstrap framework via npm. In this project, I am using node v14.18.0 through nvm.
However, when attempting to import a Bootstrap JS component (specifically 'collapse') using the following code:
import Collapse from 'bootstrap/js/src/collapse'
I encounter an issue during webpack build which results in the following error:
Module parse failed: Identifier directly after number (8:17)
You may need an appropriate loader to handle this file type, as currently no loaders are configured to process this file. Refer to https://webpack.js.org/concepts#loaders for more information.
| */
|
> const MAX_UID = 1_000_000
| const MILLISECONDS_MULTIPLIER = 1000
| const TRANSITION_END = 'transitionend'
@ ./node_modules/bootstrap/js/src/collapse.js 8:0-14:21 71:23-45 182:4-10 188:22-44 216:20-30 232:23-45 288:19-41 300:0-18
@ ./node_modules/cache-loader/dist/cjs.js??ref--1-0!./node_modules/babel-loader/lib??ref--1-1!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/gridsome/node_modules/vue-loader/lib??vue-loader-options!./src/components/Nav.vue?vue&type=script&lang=js&
@ ./src/components/Nav.vue?vue&type=script&lang=js&
It seems like webpack is having trouble parsing or reading the 'const' keyword in the imported file.
Below are the dependencies listed in my package.json file (which are up to date):
"dependencies": {
"@gridsome/plugin-sitemap": "^0.4.0",
"@popperjs/core": "^2.9.2",
"bootstrap": "^5.0.1",
"gridsome": "^0.7.0",
"gridsome-plugin-gtm": "^0.1.1",
"gsap": "^3.6.1"
},
"devDependencies": {
"node-sass": "^5.0.0",
"sass-loader": "^13.2.0",
"css-loader": "^6.7.2",
"postcss-loader": "^7.0.2",
"sass": "^1.56.1",
"style-loader": "^3.3.1"
}
If anyone has any insights or possible solutions to this issue, I would greatly appreciate it. Thank you!