Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

@parcel/core: Cannot find Parcel plugin "@parcel/transformer-typescript-types" #7197

Closed
pelikhan opened this issue Oct 26, 2021 · 13 comments
Closed

Comments

@pelikhan
Copy link

馃悰 bug report

Trying to build a TypeScript project with types leads to

@parcel/core: Cannot find Parcel plugin "@parcel/transformer-typescript-types"

馃帥 Configuration (.babelrc, package.json, cli command)

{
  "name": "test",
  "version": "0.0.0",
  "source": "src/index.ts",
  "module": "dist/module.js",
  "types": "dist/types.d.ts",
  "license": "MIT",
  "scripts": {
    "watch": "parcel watch",
    "build": "parcel build --no-autoinstall"
  },
  "devDependencies": {
    "@parcel/transformer-typescript-types": "^2.0.0",
    "parcel": "^2.0.0",
    "typescript": "^4.4.4"
  }
}

馃 Expected Behavior

Build typescript project and product .d.ts file.

馃槸 Current Behavior

$ parcel build --no-autoinstall
馃毃 Build failed.

@parcel/core: Cannot find Parcel plugin "@parcel/transformer-typescript-types"

.\node_modules\@parcel\config-default\index.json:4:26
    3 |   "transformers": {
  > 4 |     "types:*.{ts,tsx}": ["@parcel/transformer-typescript-types"],
  >   |                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Cannot find module "@parcel/transformer-typescript-types"
    5 |     "bundle-text:*": ["...", "@parcel/transformer-inline-string"],
    6 |     "data-url:*": ["...", "@parcel/transformer-inline-string"],

error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

馃捇 Code Sample

export let x = 1

馃實 Your Environment

Software Version(s)
Parcel 2.0.0
Node 14.17.6
npm/Yarn yarn 1.22
Operating System Windows, git bash
@mischnic
Copy link
Member

mischnic commented Oct 26, 2021

Using your package.json running yarn && yarn build, I got

@parcel/core: Cannot find Parcel plugin "@parcel/packager-ts"

After adding that as a dependency as well, it built successfully.

@drewdecarme
Copy link

drewdecarme commented Oct 31, 2021

I have the same issue here and the above-suggested fix didn't work for me. From what I can tell from the error report, Parcel might be trying to access the package from the wrong directory. I would expect that it would be in my node_modules but instead, the error report says it's looking for the package in the Users/my_user_name/index

$ parcel build
馃毃 Build failed.

unknown: Could not resolve module "@parcel/transformer-typescript-types" from "/Users/my_user_name/index"

I think it's also probably worth noting that I'm on a MacBook Pro running Big Sur on an Intel chip

@crunchwrapsupreme666
Copy link

I'm also running into the same issue.

@ralvapil
Copy link

ralvapil commented Nov 1, 2021

Just ran into the same error and the above workaround didn't seem to work for me either unfortunately. It seems to be something happening on MacOS machines, doesn't seem to happen on WSL for example.

@crunchwrapsupreme666
Copy link

Copy and pasting the default config's content node_modules/@parcel/config-default/index.json into the local .parcelrc seems to work.

@lann
Copy link

lann commented Nov 5, 2021

It has something to do with the project root being incorrectly set when calling parcel build with no input file. One workaround is to pass your source index, e.g. parcel build src/index.js.

For others trying to debug:
I traced the problem back to

let entryRoot = getRootDir(entries);
where entries has been resolved from the default ["."] to the directory where I ran parcel build (e.g. ["/home/lann/my-project"]). Then that line above appears to resolve to the parent of my actual project root. It then tries to find a project root from there, which of course doesn't work properly.

@icopp
Copy link

icopp commented Jan 14, 2022

Same problem here.

@saaymeen
Copy link

Can confirm this issue still persists, Parcel is looking for the module in Users/my_user_name/index.

"@parcel/packager-ts": "2.3.2"
"@parcel/transformer-typescript-types": "2.3.2"
"parcel": "^2.3.2"

@mrDarcyMurphy
Copy link

mrDarcyMurphy commented Mar 7, 2022

I ran into this as well. Deleting a stray package-lock.json and .parcel-cache in the parent folder has gotten my builds working again.

@peterhass
Copy link

peterhass commented Mar 17, 2022

I have a very similar issue here.

unknown: Could not resolve module "@parcel/transformer-yaml" from "/Users/peter/index"

Debugging into the code @lann mentioned leads me to the same observation. getRootDir sets the return value to my projects parent directory.

Another fun thing: Parcel is rewriting my package.json file to the following ....

{
  "devDependencies": {
    "@parcel/transformer-yaml": "^2.3.2"
  }
}

Update: With parcel build --no-autoinstall I don't end up with a invalid package.json file


@parcel/core: Cannot find Parcel plugin "@parcel/transformer-yaml"

  /Users/peter/Documents/Business/nebenan.de/nebenan-landing-pages/node_modules/@parcel/config-default/index.json:21:22
    20 |     "webmanifest:*.{json,webmanifest}": ["@parcel/transformer-webmanifest"],
  > 21 |     "*.{yaml,yml}": ["@parcel/transformer-yaml"],
  >    |                      ^^^^^^^^^^^^^^^^^^^^^^^^^^ Cannot find module "@parcel/transformer-yaml"
    22 |     "*.{glsl,vert,frag}": ["@parcel/transformer-glsl"],
    23 |     "*.{gql,graphql}": ["@parcel/transformer-graphql"],

Wasn't able to find a good workaround yet. Manually passing source index via cli args works for me as well so maybe I move my whole targets configuration to args? Will update this comment if I have any new findings.

Workaround: Having my own transformer config in .parcelrc
Pretty much what was mentioned here: #7197 (comment)

.babelrc

{
  "extends": "@parcel/config-default",
  "transformers": {
    "*.{yaml,yml}": ["@parcel/transformer-yaml"]
  }
}

@mischnic
Copy link
Member

This will probably be fixed with #7537

@mischnic
Copy link
Member

leads me to the same observation. getRootDir sets the return value to my projects parent directory.

This should be fixed with the current nightlies.

@Designer023
Copy link

I had these issues with a package in a pnpm monorepo.

Error: Failed to install @parcel/transformer-typescript-types: pnpm failed to install modules

Adding the dependencies in the root package.json resolved the issue for me:

"@parcel/packager-ts": "2.3.2"
"@parcel/transformer-typescript-types": "2.3.2"
"parcel": "^2.3.2"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests