plasmo icon indicating copy to clipboard operation
plasmo copied to clipboard

[BUG] pnpm build Failed to resolve

Open asyncguo opened this issue 2 years ago β€’ 9 comments

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

  • [X] I agree to follow this project's Code of Conduct
  • [X] I checked the current issues for duplicate problems.

asyncguo avatar Sep 05 '23 12:09 asyncguo

I'm having the same issue with yarn berry.

ivliag avatar Sep 08 '23 10:09 ivliag

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 avatar Sep 09 '23 18:09 Zweihander-Main

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.

Zweihander-Main avatar Sep 09 '23 20:09 Zweihander-Main

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.

louisgv avatar Sep 10 '23 03:09 louisgv

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: https://github.com/parcel-bundler/parcel/issues/7636#issuecomment-1059401129

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%"
      }
    }
  }

ivliag avatar Sep 11 '23 11:09 ivliag

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

asyncguo avatar Sep 13 '23 11:09 asyncguo

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

xiaokaike avatar Dec 14 '23 08:12 xiaokaike

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.

lnoss avatar Dec 19 '23 11:12 lnoss

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

jacky1234 avatar May 08 '24 09:05 jacky1234