extension-js / extension.js

🧩 The cross-browser extension framework.
https://extension.js.org
MIT License
3.8k stars 97 forks source link

Error: ENOENT: no such file or directory #168

Closed OSpoon closed 2 months ago

OSpoon commented 2 months ago

The path for the template cannot be found in development mode.

➜  extension.js git:(content-css-options) βœ— nr extension create ../content-less-ext --template content-less

> extension@ extension /Users/xinzhang/Documents/GitHub/extension.js
> dotenv -- ts-node ./programs/cli/dist/cli.js "create" "../content-less-ext" "--template" "content-less"

🐣 - Starting a new browser extension named content-less-ext...
🀝 - Ensuring content-less-ext folder exists...
🀞 - Checking if destination path is writeable...
πŸ”Ž - Scanning for potential conflicting files...
🧰 - Installing content-less-ext from template content-less...
βœ–οΈŽβœ–οΈŽβœ–οΈŽ Can't find template content-less for content-less-ext:
Error: ENOENT: no such file or directory, lstat '/Users/xinzhang/Documents/GitHub/extension.js/node_modules/.pnpm/extension-create@2.0.0-alpha.23/examples/content-less'
    at async lstat (node:internal/fs/promises:1021:18)
    at async Promise.all (index 0)
    at async checkPaths (node:internal/fs/cp/cp:76:39)
    at async cpFn (node:internal/fs/cp/cp:65:17)
    at async Fe (/Users/xinzhang/Documents/GitHub/extension.js/node_modules/.pnpm/extension-create@2.0.0-alpha.23/node_modules/extension-create/dist/module.js:28:2138)
    at async ln (/Users/xinzhang/Documents/GitHub/extension.js/node_modules/.pnpm/extension-create@2.0.0-alpha.23/node_modules/extension-create/dist/module.js:38:771)
    at async Command.<anonymous> (/Users/xinzhang/Documents/GitHub/extension.js/programs/cli/dist/cli.js:197:3) {
  errno: -2,
  code: 'ENOENT',
  syscall: 'lstat',
  path: '/Users/xinzhang/Documents/GitHub/extension.js/node_modules/.pnpm/extension-create@2.0.0-alpha.23/examples/content-less'
}
 ELIFECYCLE  Command failed with exit code 1.
cezaraugusto commented 2 months ago

oh noes that's bad :_(

just released alpha@24, might giving it a go?

pnpm extension@latest create ../content-less-ext --template content-less
Screenshot 2024-09-06 at 11 29 50
OSpoon commented 2 months ago

oh noes that's bad :_(

just released alpha@24, might giving it a go?

pnpm extension@latest create ../content-less-ext --template content-less
Screenshot 2024-09-06 at 11 29 50

Path issues only occur in development mode, I need to use the local template.

cezaraugusto commented 2 months ago

cant repro as well 😒

Screenshot 2024-09-06 at 13 18 52
cezaraugusto commented 2 months ago

I did found an issue with the symlink if EXTENSION_ENV=development is set. not sure if related

Screenshot 2024-09-06 at 13 23 14
OSpoon commented 2 months ago

Need to handle the symlink issue first, then we can determine if the code runs correctly.

// programs/create/steps/import-external-template.ts

if (process.env.EXTENSION_ENV === 'development') {
  console.log(messages.installingFromTemplate(projectName, template))

  templatePath = path.join(projectPath, templateName)

  await fs.cp(
    path.join(__dirname, '..', '..', '..', 'examples', templateName),
    templatePath,
    {recursive: true}
  )
}
dshook commented 2 months ago

Just ran into this as well, latest doesn't work for me either:

npx extension@latest create test-extension --template=react-typescript

Need to install the following packages:
extension@2.0.0-alpha.26
Ok to proceed? (y) y
🐣 - Starting a new browser extension named cat-search...
🀝 - Ensuring cat-search folder exists...
🀞 - Checking if destination path is writeable...
πŸ”Ž - Scanning for potential conflicting files...
🧰 - Installing cat-search from template react-typescript...
Removing existing .go-git-it-temp-folder...
[=                                                 ] 2% 18.5sError pulling git repository: [Error: ENOENT: no such file or directory, rename 'examples/react-typescript' -> '/Users/dillonshook/react-typescript'] {
  errno: -2,
  code: 'ENOENT',
  syscall: 'rename',
  path: 'examples/react-typescript',
  dest: '/Users/dillonshook/react-typescript'
}
OSpoon commented 2 months ago

After running cleanInstall, I re-ran the previous create command, and found that there was no issue, which seems to be caused by caching.

cezaraugusto commented 2 months ago

thanks @OSpoon!

@dshook I made a few changes to the template names, please check https://extension.js.org/docs/getting-started/templates for the new template naming. I'm going to close this one for now, please re-open if there's an issue. Thanks!

takanuva15 commented 1 month ago

@cezaraugusto Hey I just tried out the sample doc command today and got the same error as OP:

C:\Users\me\Documents\Repositories>npx extension@latest create my-extension --template=react-typescript
🐣 - Starting a new browser extension named my-extension...
🀝 - Ensuring my-extension folder exists...
🀞 - Checking if destination path is writeable...
πŸ”Ž - Scanning for potential conflicting files...
🧰 - Installing my-extension from template react-typescript...
[==                                                ] 3% 18.7sError pulling git repository: [Error: ENOENT: no such file or directory, rename 'C:\Users\me\Documents\Repositories\.go-git-it-temp-folder\examples\react-typescript' -> 'C:\Users\me\Documents\Repositories\react-typescript'] {
  errno: -4058,
  code: 'ENOENT',
  syscall: 'rename',
  path: 'C:\\Users\\me\\Documents\\Repositories\\.go-git-it-temp-folder\\examples\\react-typescript',
  dest: 'C:\\Users\\me\\Documents\\Repositories\\react-typescript'
}

EDIT: Looking in the examples folder, I don't even see a folder called "react-typescript". Was it deleted?

EDIT2: Okay, after looking at the examples further, it seems the "react" example already has typescript configured. Thus it looks like the docs are simply out-of-date. You can just run npx extension@latest create my-extension --template=new-react to have both react and typescript configured at once. (Change the template to content-react if your extension will be editing existing webpages)