Koala7 Koala7 - 1 year ago 118
Node.js Question

TypeError: React.renderToStaticMarkup is not a function

I am following this tutorial "Building SVG Icons with React"


I am getting stuck when i am running the command

"npm run build"

This is the

0 info it worked if it ends with ok
1 verbose cli [ '/Users/villat/.nvm/versions/node/v5.0.0/bin/node',
1 verbose cli '/Users/villat/.nvm/versions/node/v5.0.0/bin/npm',
1 verbose cli 'run',
1 verbose cli 'build' ]
2 info using npm@3.3.6
3 info using node@v5.0.0
4 verbose run-script [ 'prebuild', 'build', 'postbuild' ]
5 info lifecycle react-icons@1.0.0~prebuild: react-icons@1.0.0
6 silly lifecycle react-icons@1.0.0~prebuild: no script for prebuild, continuing
7 info lifecycle react-icons@1.0.0~build: react-icons@1.0.0
8 verbose lifecycle react-icons@1.0.0~build: unsafe-perm in lifecycle true
9 verbose lifecycle react-icons@1.0.0~build: PATH: /Users/villat/.nvm/versions/node/v5.0.0/lib/node_modules/npm/bin/node-gyp-bin:/Users/villat/Downloads/Projects/react-icons/node_modules/.bin:/Users/villat/.nvm/versions/node/v5.0.0/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
10 verbose lifecycle react-icons@1.0.0~build: CWD: /Users/villat/Downloads/Projects/react-icons
11 silly lifecycle react-icons@1.0.0~build: Args: [ '-c', 'node build' ]
12 silly lifecycle react-icons@1.0.0~build: Returned: code: 1 signal: null
13 info lifecycle react-icons@1.0.0~build: Failed to exec build script
14 verbose stack Error: react-icons@1.0.0 build: `node build`
14 verbose stack Exit status 1
14 verbose stack at EventEmitter.<anonymous> (/Users/villat/.nvm/versions/node/v5.0.0/lib/node_modules/npm/lib/utils/lifecycle.js:233:16)
14 verbose stack at emitTwo (events.js:87:13)
14 verbose stack at EventEmitter.emit (events.js:172:7)
14 verbose stack at ChildProcess.<anonymous> (/Users/villat/.nvm/versions/node/v5.0.0/lib/node_modules/npm/lib/utils/spawn.js:24:14)
14 verbose stack at emitTwo (events.js:87:13)
14 verbose stack at ChildProcess.emit (events.js:172:7)
14 verbose stack at maybeClose (internal/child_process.js:818:16)
14 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:211:5)
15 verbose pkgid react-icons@1.0.0
16 verbose cwd /Users/villat/Downloads/Projects/react-icons
17 error Darwin 15.4.0
18 error argv "/Users/villat/.nvm/versions/node/v5.0.0/bin/node" "/Users/villat/.nvm/versions/node/v5.0.0/bin/npm" "run" "build"
19 error node v5.0.0
20 error npm v3.3.6
21 error code ELIFECYCLE
22 error react-icons@1.0.0 build: `node build`
22 error Exit status 1
23 error Failed at the react-icons@1.0.0 build script 'node build'.
23 error This is most likely a problem with the react-icons package,
23 error not with npm itself.
23 error Tell the author that this fails on your system:
23 error node build
23 error You can get their info via:
23 error npm owner ls react-icons
23 error There is likely additional logging output above.
24 verbose exit [ 1, true ]

In attached my terminal screenshot where it is complaining about

enter image description here

I have done a bit of research and i have not found any relevant solution for me

I am using nvm to manage the node versions

My node -v version is

Answer Source

renderToStaticMarkup has moved to react-dom/server.


You need to install react-dom.

npm install react-dom

And use it.

var ReactDOMServer = require('react-dom/server');
ReactDOMServer.renderToStaticMarkup(<div />);