I use useImmer in react project. Locally, everything starts, but in Github Actions and when deploying in Vercel, an error occurs with Immer. As I understand it, it does not find the required module.
import React, { useState } from 'react';
import { useImmer } from 'use-immer';
import getModal from './modals/index';
And the tests don't work because of the error.
GitHub Actions:
npm test -s
FAIL __tests__/test.jsx
● Test suite failed to run
Cannot find module 'immer' from 'node_modules/use-immer/dist/use-immer.js'
Require stack:
node_modules/use-immer/dist/use-immer.js
src/App.jsx
__tests__/test.jsx
at Resolver.resolveModule (node_modules/jest-resolve/build/resolver.js:311:11)
at Object.<anonymous> (node_modules/use-immer/dist/use-immer.js:1:94)
And the deployment does not work.
Vercel:
15:11:16.184 ERROR in ./node_modules/use-immer/dist/use-immer.module.js 1:0-21
15:11:16.184 Module not found: Error: Can't resolve 'immer' in '/vercel/path0/node_modules/use-immer/dist'
I use useImmer in react project. Locally, everything starts, but in Github Actions and when deploying in Vercel, an error occurs with Immer. As I understand it, it does not find the required module.
import React, { useState } from 'react';
import { useImmer } from 'use-immer';
import getModal from './modals/index';
And the tests don't work because of the error.
GitHub Actions:
npm test -s
FAIL __tests__/test.jsx
● Test suite failed to run
Cannot find module 'immer' from 'node_modules/use-immer/dist/use-immer.js'
Require stack:
node_modules/use-immer/dist/use-immer.js
src/App.jsx
__tests__/test.jsx
at Resolver.resolveModule (node_modules/jest-resolve/build/resolver.js:311:11)
at Object.<anonymous> (node_modules/use-immer/dist/use-immer.js:1:94)
And the deployment does not work.
Vercel:
15:11:16.184 ERROR in ./node_modules/use-immer/dist/use-immer.module.js 1:0-21
15:11:16.184 Module not found: Error: Can't resolve 'immer' in '/vercel/path0/node_modules/use-immer/dist'
Share
Improve this question
edited Jun 22, 2021 at 16:50
Sergey Kirillov
asked Jun 22, 2021 at 15:46
Sergey KirillovSergey Kirillov
6812 gold badges6 silver badges11 bronze badges
2 Answers
Reset to default 2Check whether immer
is added as a dependency in your package.json
. It's mentioned in peerDependencies
of use-immer
.
I just ran into this same issue, but solved it by installing immer
as a seperate dependency. (i.e. yarn install immer use-immer
). This also seems to be the solution on the official npmjs website: https://www.npmjs./package/use-immer.