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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] pnpm build Failed to resolve #750

Open
2 of 3 tasks
asyncguo opened this issue Sep 5, 2023 · 9 comments
Open
2 of 3 tasks

[BUG] pnpm build Failed to resolve #750

asyncguo opened this issue Sep 5, 2023 · 9 comments
Labels
bug Something isn't working

Comments

@asyncguo
Copy link

asyncguo commented Sep 5, 2023

What happened?

This prompts when pnpm build, but there is no problem when pnpm dev.

Version

Latest

What OS are you seeing the problem on?

MacOSX

What browsers are you seeing the problem on?

Chrome

Relevant log output

🟣 Plasmo v0.82.5
🔴 The Browser Extension Framework
🔵 INFO   | Prepare to bundle the extension...
🔵 INFO   | Loaded environment variables from: []
🔴 ERROR  | Failed to resolve '../../../background/index' from './.plasmo/static/background/index.ts'
🔴 EXIT   | 👋 Good bye and have a great day!
 ELIFECYCLE  Command failed with exit code 1.

(OPTIONAL) Contribution

  • I would like to fix this BUG via a PR

Code of Conduct

  • I agree to follow this project's Code of Conduct
  • I checked the current issues for duplicate problems.
@asyncguo asyncguo added the bug Something isn't working label Sep 5, 2023
@ivliag
Copy link

ivliag commented Sep 8, 2023

I'm having the same issue with yarn berry.

@Zweihander-Main
Copy link

Also have had this problem for a bit but just got to creating a reproduction.

When using the src dir, this happens with either a background/index.ts or background.ts structure. When using the non-src default structure, it seems to only happen when using background/index.ts but works when using background.ts.

plasmo build --verbose:

🟡 0      | Running command: build
🟣 Plasmo v0.83.0
🔴 The Browser Extension Framework
🔵 INFO   | Prepare to bundle the extension...
🟡 1      | Creating Manifest Factory...
🟡 2      | Ensure exists: /project/home/zweihander-main/workspace/.plasmo
🟡 3      | Plasmo version file not found, busting cache...
🟡 4      | /project/home/zweihander-main/workspace/assets/icon.png found, creating resized icons
🟡 5      | Creating static templates for popup
🟡 6      | Creating static templates for options
🟡 7      | Creating static templates for newtab
🟡 8      | Creating static templates for devtools
🟡 9      | Creating static templates for sidepanel
🟡 10     | { messageHandlerList: [], portHandlerList: [] }
🟡 11     | Creating BGSW entry
🟡 12     | Hash changed, updating manifest
🔵 INFO   | Loaded environment variables from: []
🟡 0      | Reinitializing remote cache directory
🟡 0      | @plasmohq/parcel-transformer-manifest
🟡 1      | Adding icons
🟡 2      | Adding default_icon
🟡 3      | Handling background scripts
🟡 4      | Handling background service worker
🔴 ERROR  | Failed to resolve '../../../background/index' from './.plasmo/static/background/index.ts'
🟡 13     | undefined
🔴 EXIT   | 👋 Good bye and have a great day!

OS: Arch Linux 6.4.12

@Zweihander-Main
Copy link

Update: cracked it on my end. On both the repro above and my own project, the package.json had a "main": "index.js" line which when removed, eliminated the problem.

@louisgv
Copy link
Contributor

louisgv commented Sep 10, 2023

I think it's either the main field that @Zweihander-Main got (which made the repo a cjs project). The other is that you might need to check and fix the tsconfig path :-?..

Also try cleaning up the .plasmo dir and re-build.

@ivliag
Copy link

ivliag commented Sep 11, 2023

In my case, the problem was that I had engines.node in my package.json set like this:

  "engines": {
    "node": ">=18"
  }

And there is an issue in parcel-bundler describing this exact problem:
parcel-bundler/parcel#7636 (comment)

So I just had to add the target to my package.json, so it works like this:

  "engines": {
    "node": ">=18"
  },
  "targets": {
    "default": {
      "engines": {
        "browsers": "last 2 versions, not dead, > 0.2%"
      }
    }
  }

@asyncguo
Copy link
Author

In my case, the problem was that I had engines.node in my package.json set like this:

  "engines": {
    "node": ">=18"
  }

And there is an issue in parcel-bundler describing this exact problem: parcel-bundler/parcel#7636 (comment)

So I just had to add the target to my package.json, so it works like this:

  "engines": {
    "node": ">=18"
  },
  "targets": {
    "default": {
      "engines": {
        "browsers": "last 2 versions, not dead, > 0.2%"
      }
    }
  }

me too

jterskine added a commit to jterskine/twitter-headlines that referenced this issue Oct 8, 2023
```
yarn build
yarn run v1.22.19
$ plasmo build
🟣 Plasmo v0.83.0
🔴 The Browser Extension Framework
🔵 INFO   | Prepare to bundle the extension...
🔵 INFO   | Loaded environment variables from: []
🔴 ERROR  | Failed to resolve '../../../background' from './.plasmo/static/background/index.ts'
🔴 EXIT   | 👋 Good bye and have a great day!
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
```
see PlasmoHQ/plasmo#750 (comment)
aiktb pushed a commit to aiktb/DontTranslateCode that referenced this issue Oct 14, 2023
aiktb pushed a commit to aiktb/FuriganaMaker that referenced this issue Oct 15, 2023
@xiaokaike
Copy link

In my case, the problem was that I had engines.node in my package.json set like this:

  "engines": {
    "node": ">=18"
  }

And there is an issue in parcel-bundler describing this exact problem: parcel-bundler/parcel#7636 (comment)

So I just had to add the target to my package.json, so it works like this:

  "engines": {
    "node": ">=18"
  },
  "targets": {
    "default": {
      "engines": {
        "browsers": "last 2 versions, not dead, > 0.2%"
      }
    }
  }

me too, think you very much

@lnoss
Copy link

lnoss commented Dec 19, 2023

So I am not alone. This issue is closed on Parcel without an explanation... Removing the engines.node key or keeping it while adding browsers definitely work. For whatever it means. This looks like misuses of keys.

aiktb pushed a commit to aiktb/FuriganaMaker that referenced this issue Mar 16, 2024
aiktb added a commit to aiktb/FuriganaMaker that referenced this issue Mar 16, 2024
aiktb added a commit to aiktb/FuriganaMaker that referenced this issue Mar 16, 2024
aiktb added a commit to aiktb/FuriganaMaker that referenced this issue Mar 16, 2024
aiktb added a commit to aiktb/FuriganaMaker that referenced this issue Mar 16, 2024
@jacky1234
Copy link

remove "engines" config in package.json fixed my issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

7 participants