New project created with pnpm as package manager doesnot work correctly:
ready - started server on 0.0.0.0:3000, url: http://localhost:3000
info - Using webpack 5. Reason: Enabled by default https://nextjs.org/docs/messages/webpack5
info - Using external babel configuration from /Users/linbudu/Desktop/OPEN_SOURCE/blitz-example/babel.config.js
error - ../../../.nvm/versions/node/v14.17.4/pnpm-global/5/node_modules/.pnpm/styled-jsx@4.0.0/node_modules/styled-jsx/dist/style.js:7:0
Module not found: Can't resolve 'react'
Import trace for requested module:
./../../../.nvm/versions/node/v14.17.4/pnpm-global/5/node_modules/.pnpm/styled-jsx@4.0.0/node_modules/styled-jsx/style.js
./app/core/components/Form.tsx
./app/auth/components/LoginForm.tsx
./app/pages/_app.tsx
https://nextjs.org/docs/messages/module-not-found
Seems like styled-jsx is dependency of next, when installing packages which are not listed in package.json, pnpm put it in the global store, so when styled-jsx is requiring react, as node's dep resolution it search for the global(if we install react globally like pnpm install react -g, this error was resolved).
If we install styled-jsx locally, then it requires the local installed react package, which makes project work normally, but this doesnot seem to be a excellent solution, only install styled-jsx in pnpm project? add styled-jsx for all package manager with actual version required by next?
Also, @types/node should also be added to package.json to avoid errors:
It looks like you're trying to use TypeScript but do not have the required package(s) installed.
Please install @types/node by running:
npm install --save-dev @types/node
If you are not trying to use TypeScript, please remove the tsconfig.json file from your package root (and any TypeScript files in your pages directory).
Paste all your error logs here:
ready - started server on 0.0.0.0:3000, url: http://localhost:3000
info - Using webpack 5. Reason: Enabled by default https://nextjs.org/docs/messages/webpack5
info - Using external babel configuration from /Users/linbudu/Desktop/OPEN_SOURCE/blitz-example/babel.config.js
error - ../../../.nvm/versions/node/v14.17.4/pnpm-global/5/node_modules/.pnpm/styled-jsx@4.0.0/node_modules/styled-jsx/dist/style.js:7:0
Module not found: Can't resolve 'react'
Import trace for requested module:
./../../../.nvm/versions/node/v14.17.4/pnpm-global/5/node_modules/.pnpm/styled-jsx@4.0.0/node_modules/styled-jsx/style.js
./app/core/components/Form.tsx
./app/auth/components/LoginForm.tsx
./app/pages/_app.tsx
https://nextjs.org/docs/messages/module-not-found
What is the problem?
New project created with pnpm as package manager doesnot work correctly:
Seems like
styled-jsx
is dependency ofnext
, when installing packages which are not listed in package.json, pnpm put it in the global store, so whenstyled-jsx
is requiringreact
, as node's dep resolution it search for the global(if we install react globally likepnpm install react -g
, this error was resolved).If we install
styled-jsx
locally, then it requires the local installedreact
package, which makes project work normally, but this doesnot seem to be a excellent solution, only installstyled-jsx
in pnpm project? addstyled-jsx
for all package manager with actual version required bynext
?Also,
@types/node
should also be added to package.json to avoid errors:Paste all your error logs here:
Paste all relevant code snippets here:
What are detailed steps to reproduce this?
blitz new myApp
, and choose pnpm as package manager.blitz dev
.pnpm i styled-jsx
, and rerunblitz dev
.Run
blitz -v
and paste the output here:Please include below any other applicable logs and screenshots that show your problem:
No response