5

I am trying to run npm start on react and am coming up with the following error. I have tried re-installing npm and node.js. Error bind is not a function error continues to come up. What am I missing?

PS C:\Users\XXXXXXXXXX> npm run start

\XXXXXXXXX\node_modules\renderkid\node_modules\domutils\index.js:12
                DomUtils[key] = ext[key].bind(DomUtils);
                                         ^

TypeError: ext[key].bind is not a function
    at C:\XXXXXXXXXXXX\node_modules\renderkid\node_modules\domutils\index.js:12:28
    at Array.forEach (<anonymous>)
    at C:\XXXXXXXXXXXX\node_modules\renderkid\node_modules\domutils\index.js:11:19
    at Array.forEach (<anonymous>)
    at Object.<anonymous> (XXXXXXXXXXXX\node_modules\renderkid\node_modules\domutils\index.js:10:3)
    at Module._compile (internal/modules/cjs/loader.js:1063:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
    at Module.load (internal/modules/cjs/loader.js:928:32)
    at Function.Module._load (internal/modules/cjs/loader.js:769:14)
    at Module.require (internal/modules/cjs/loader.js:952:19)
npm ERR! code 1
npm ERR! command failed
npm ERR! command C:\WINDOWS\system32\cmd.exe /d /s /c set PORT=3005 && react-scripts start

This is were the DomUtils is being called out in node_modules > Domutils > index.js

var DomUtils = module.exports;

[
    require("./lib/stringify"),
    require("./lib/traversal"),
    require("./lib/manipulation"),
    require("./lib/querying"),
    require("./lib/legacy"),
    require("./lib/helpers")
].forEach(function(ext){
    Object.keys(ext).forEach(function(key){
        DomUtils[key] = ext[key].bind(DomUtils);
    });
});
RogerJoe
  • 91
  • 2
  • 5
  • Seems that the same problem was described here https://stackoverflow.com/questions/38122544/webpack-error-while-loading-module-domutils-after-import-enzyme and solution also placed there – Serhii Onishchenko Mar 29 '21 at 15:19
  • 1
    @Serj Thank you for this information. Although this problem looks similar, it does not seem like the solution will work for me while working in Node.js I am unable to find where to put domutils in the webpack. – RogerJoe Mar 29 '21 at 19:45
  • @RogerJoe did you figure out what caused this issue? I am also running into this. Thanks! – Bill Jun 21 '21 at 12:39
  • Did you find a solution? Stuck with this exact same thing – Rene Trujillo Aug 13 '21 at 06:48

3 Answers3

0

I am using docker for first time to build a react application and host on ngnix, I have faced the same issue while building image for react application.

I used the following script to build the image and it helped, I have changed nodeJS version from node:7.10 to node:14.1-alpine.

Here is my Docker file

 FROM node:14.1-alpine AS builder

WORKDIR /opt/web
COPY package.json package-lock.json ./
RUN npm install

ENV PATH="./node_modules/.bin:$PATH"

COPY . ./
RUN npm run build

FROM nginx:1.17.1-alpine

COPY --from=builder /opt/web/build /usr/share/nginx/html

Hope this is helpful for someone trying to build docker image for react application and host on ngnix.

sri e
  • 49
  • 1
  • 5
0

I faced the same error. I did an npm install on my project git repository which modified by package-lock.json and consequently doing npm run start brought up this error. In order to fix this, I restored my package-lock.json , did an npm ci instead and then doing npm run start worked.

SabU
  • 603
  • 6
  • 4
0

Try restoring your project & run npm ci instead of npm install it worked for me , for some reason npm install corrupts your lockfile.