You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Dec 30, 2021. It is now read-only.
Using CSA with the --template @snowpack/app-template-react-typescript and --use-pnpm option together, the resulting bootstrapped app will fail to start or build.
mount:web_modules.......[DONE] mount $WEB_MODULES --to /web_modules
mount:public............[DONE] mount public --to /
mount:src...............[DONE] mount src --to /_dist_
run:tsc.................[WATCH] tsc --noEmit
build:js,jsx,ts,tsx.....[ERROR] (plugin) @snowpack/plugin-babel
Reproduce
pnpx create-snowpack-app react-snowpack --template @snowpack/app-template-react-typescript --use-pnpm
pnpm run start
# or
pnpm run build
Cause
By default, pnpm creates a non-flat node_modules folder. Phantom dependencies will raise missing module errors. For example, running pnpm run build leads to the following error:
Cannot find module '@babel/plugin-syntax-import-meta' from '<project_folder>/node_modules/@snowpack/app-scripts-react'
Missing Plugins
For snowpack build and development, the missing plugins are:
There are potentially many more, but that'd depend on the specific webpack config passed to the bundler.
Workaround / Fix
My current workaround is to add the missing dependencies once they are found. Another workaround would be to set the shamefully-hoist option to true in the .npmrc file. This is indeed what Vue CLI did (don't know currently).
Perhaps a more permanent solution would be to implement something similar to eject for pnpm installs so that all required dependencies are hoisted.
Edit: I haven't tested other templates, but I suspect this issue is not exclusive to the react template. Any framework that relies on dependency hoisting to bootstrap should run into the same problem.
The text was updated successfully, but these errors were encountered:
In most cases it means that one of the dependencies require packages not declared in package.json. It is a common mistake caused by flat node_modules. If this happens, this is an error in the dependency and the dependency should be fixed. That might take time though, so pnpm supports workarounds to make the buggy packages work.
...
Description
Using
CSA
with the--template @snowpack/app-template-react-typescript
and--use-pnpm
option together, the resulting bootstrapped app will fail to start or build.Reproduce
pnpx create-snowpack-app react-snowpack --template @snowpack/app-template-react-typescript --use-pnpm pnpm run start # or pnpm run build
Cause
By default,
pnpm
creates a non-flatnode_modules
folder. Phantom dependencies will raise missing module errors. For example, runningpnpm run build
leads to the following error:Missing Plugins
For snowpack build and development, the missing plugins are:
Once a bundler is connected, more missing dependency errors arise. For example, using
@snowpack/plugin-webpack
:There are potentially many more, but that'd depend on the specific webpack config passed to the bundler.
Workaround / Fix
My current workaround is to add the missing dependencies once they are found. Another workaround would be to set the
shamefully-hoist
option totrue
in the.npmrc
file. This is indeed what Vue CLI did (don't know currently).Perhaps a more permanent solution would be to implement something similar to
eject
for pnpm installs so that all required dependencies are hoisted.Edit: I haven't tested other templates, but I suspect this issue is not exclusive to the react template. Any framework that relies on dependency hoisting to bootstrap should run into the same problem.
The text was updated successfully, but these errors were encountered: