npm link react-redux fail

Viewed 157

Im building react component library.

I need to 'npm link' my library project to use react-redux located in main project

I do it like 'npm link ../MainProject/node_modules/react-redux'

but it give me an error:

npm ERR! code 1
npm ERR! path C:\Users\jamal\WorkspaceAmavisca\Cerebrum-Administration\node_modules\react-redux
npm ERR! command failed
npm ERR! command C:\Windows\system32\cmd.exe /d /s /c npm run clean && npm run build
npm ERR! > react-redux@7.2.6 clean
npm ERR! > rimraf lib dist es coverage
npm ERR!
npm ERR!
npm ERR! > react-redux@7.2.6 build
npm ERR! > npm run build:commonjs && npm run build:es && npm run build:umd && npm run build:umd:min
npm ERR!
npm ERR!
npm ERR! > react-redux@7.2.6 build:commonjs
npm ERR! > cross-env BABEL_ENV=commonjs babel src --out-dir lib
npm ERR! 'cross-env' is not recognized as an internal or external command,
npm ERR! operable program or batch file.

when I install cross-env as global, then try to npm link again. it give me error:

> npm ERR! Error: spawn babel ENOENT npm ERR! at notFoundError
> (C:\Users\jamal\Apps\nvm\v16.13.1\node_modules\cross-env\node_modules\cross-spawn\lib\enoent.js:6:26)

apparently when I do npm link, it seems react-redux run their build script again but fail.

any help?

thanks

  • React-Redux: 7.2.1 and 7.2.6
  • React: 16.14.0
  • ReactDOM: 16.14.0
  • Redux:4.0.5 React
  • Redux:7.2.1
  • Node 16.13.1
  • NPM: 8.1.2
1 Answers

Instead of using npm link. Resolve by using alias in your main project if you are using webpack

alias: {
    "react-redux": path.resolve('./node_modules/react-redux'),
    "react": path.resolve('./node_modules/react'),
}
Related