Hello
I just published on npm a custom react component (date picker), for learning purposes. Alone, this component and my main app worked. But after installing my home made package in my main project, I have this kind of error.
Compiled with problems:X
ERROR in ./node_modules/rc_openclassrooms_datepicker/components/DatePicker.jsx 74:21
Module parse failed: Unexpected token (74:21)
File was processed with these loaders:
* ./node_modules/source-map-loader/dist/cjs.js
You may need an additional loader to handle the result of these loaders.
| let yearOptions = []
| for (let year = 1950; year < 2051; year++) {
> yearOptions.push(<option key={year} value={year}>{year}</option>)
| }
|
Here is the package.json of my custom lib:
{
"name": "rc_openclassrooms_datepicker",
"version": "1.0.2",
"main": "index.js",
"licence": "ISC",
"private": false,
"description": "datepicker component for personnal openclassrooms hrnet project",
"repository": {
"type": "git",
"url": "git+https://github.com/Keitaro51/P14_OC_Front-end_HRNet_datePicker.git"
},
"peerDependencies": {
"react": "^17.0.2",
"react-dom": "^17.0.2"
}
}
and for my main project
{
"name": "hrnet_react",
"version": "0.1.0",
"private": true,
"dependencies": {
"@reduxjs/toolkit": "^1.8.0",
"prop-types": "^15.8.1",
"rc_openclassrooms_datepicker": "^1.0.2",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-redux": "^7.2.6",
"react-router-dom": "^6.2.2",
"react-scripts": "5.0.0",
"redux": "^4.1.2",
"uuid": "^8.3.2",
"web-vitals": "^2.1.4"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject",
"doc": "jsdoc src -r -d ./docs"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
Here is the way I install and import it in my project
npm i rc_openclassrooms_datepicker
then
import { DatePicker } from 'rc_openclassrooms_datepicker/index'
Thank you in advance
What I have tried:
I searched for same issues on web, stackoverflow. Many results but not adapted and too technical for my level.
I review the base code in my node module package, tried different type of import