craftcms / nitro

Speedy local dev environment for @craftcms.
https://getnitro.sh
MIT License
178 stars 24 forks source link

`npx` support? #362

Closed proimage closed 2 years ago

proimage commented 3 years ago

Description

According to the latest Laravel Mix docs, the command to compile things has changed from npm run ____ to npx mix. While Nitro supports npm, it doesn't appear to support npx.

jasonmccallister commented 3 years ago

@proimage I'm taking a guess that this is related https://discord.com/channels/456442477667418113/707324026577485934/845745476003430490

We are making some changes to the base images that Nitro uses to better support things such as controlling the node versions which will also mean the npx command can be included. In your Discord message you were trying nitro npx but nitro ssh and the instructions for installing npx should also work.

proimage commented 3 years ago

nitro ssh? Hmm, perhaps you think me to be more knowledgeable than I am. 🤣 I've already got Laravel Mix installed. I thought that comes with npx already, since it's compile command uses npx.

Regardless, where does nitro ssh come in? It looks like that connects me to the container's shell, I guess? Once there, I presume I can run things like npm run ___ directly, without having to prefix it with nitro all the time? That would be handy in and of itself.

proimage commented 3 years ago

This has come back to bite me in the rear again... can I have some specific instructions on how to get things working?

For the record, here's what I'm trying:

me@MyPC:~/projects/myProject$ nitro npm run watch
  … checking /home/me/projects/myProject/package.json ✓
  … pulling docker.io/library/node:14-alpine ✓
Running npm run

> @ watch /home/node/app
> mix watch

npx: installed 71 in 8.224s
CLI for webpack must be installed.
  webpack-cli (https://github.com/webpack/webpack-cli)

We will use "npm" to install the CLI via "npm install -D webpack-cli".
Do you want to install 'webpack-cli' (yes/no): npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ watch: `mix watch`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the @ watch script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2021-11-14T18_20_15_756Z-debug.log
npm run complete 🤘

Seeing the failure at installing the webpack-cli, I tried to do that manually, and it seemed to work:

me@MyPC:~/projects/myProject$ nitro npm install webpack-cli
  … checking /home/me/projects/myProject/package.json ✓
  … pulling docker.io/library/node:14-alpine ✓
Running npm install
npm WARN read-shrinkwrap This version of npm is compatible with lockfileVersion@1, but package-lock.json was generated for lockfileVersion@2. I'll try to do my best with it!
npm WARN browser-sync-webpack-plugin@2.2.2 requires a peer of webpack@^1 || ^2 || ^3 || ^4 but none is installed. You must install peer dependencies yourself.
npm WARN laravel-mix-polyfill@1.1.0 requires a peer of laravel-mix@^4.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN sass-loader@7.3.1 requires a peer of webpack@^3.0.0 || ^4.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN app No description
npm WARN app No repository field.
npm WARN app No license field.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.3.2 (node_modules/browser-sync/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.3.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.3.2 (node_modules/laravel-mix/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.3.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.1.3 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.3.2 (node_modules/webpack-dev-server/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.3.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

+ webpack-cli@4.9.1
updated 1 package and audited 1368 packages in 8.679s

91 packages are looking for funding
  run `npm fund` for details

found 74 vulnerabilities (31 moderate, 43 high)
  run `npm audit fix` to fix them, or `npm audit` for details
npm install complete 🤘

But it makes no difference to the nitro npm run watch command.

Then I tried:

me@MyPC~/projects/myProject$ nitro ssh
connecting to my-project.nitro
/app $ npm run watch

> watch
> mix watch

sh: webpack: Permission denied
/app $ 

And with that, I'm stumped. Any ideas?

jasonmccallister commented 2 years ago

Hi, we are closing this issue as we have decided to retire Nitro, so no additional work will occur on this project. You can read the official blog post here https://craftcms.com/blog/retiring-craft-nitro. We appreciate everyones feedback and involvement and we look forward to refocusing our efforts on Cloud!

If you're looking for a new local development environment, we recommend DDEV and have a knowledge base article to help you with the transition: https://craftcms.com/knowledge-base/migrating-from-craft-nitro-to-ddev.