Click here to Skip to main content
15,900,816 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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+"
  "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": [
  "browserslist": {
    "production": [
      "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

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
Updated 13-Apr-22 6:34am

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900