Skip to content

Latest commit

 

History

History
84 lines (50 loc) · 1.84 KB

nodejs.md

File metadata and controls

84 lines (50 loc) · 1.84 KB

Node.js

The latest LTS version of Node.js is pre-installed the newest PHP container.

This was a deliberate decision in order to keep the PHP containers as small as possible, but still provide the convenience of having these tools available.

If your PHP-based website requires an older PHP, that's ok. Keep running it in the older PHP container and use the newest PHP container for Node.js based tooling.

Troubleshooting: Node isn't working / not installed

Make sure you are inside the newest PHP container. For example:

devin 83

Then check the version of Node.js:

node -v

If you get an error like bash: node: command not found, you're using the wrong command shell. This might also be because you're using outdated aliases.

Follow the "Daily Shortcuts" section again in the README to update your aliases. Then run devin 83 again and check the Node.js version.

If you're manually running docker exec -it php83 bash, you'll need to update the command to docker exec -it php83 zsh (ie. use ZSH instead of BASH).

Node Version Manager (NVM)

It's likely that you'll want to use a range of Node.js version for your projects, so we've pre-installed NVM to make switching between them easy.

List all currently installed versions:

nvm ls

Install an older version (eg. v18.x):

nvm install 18

Start using a specific version (eg. v18.x):

nvm use 18

Check which version is currently active:

node -v

Discover the other features of NVM:

nvm --help

Can I use the latest (non-LTS) version of Node.js?

Sure, just run:

nvm install node

Please note the latest version may be newer than the current LTS version, so be aware of the potential for breaking changes in your projects.

How do I run NPM scripts?

devin 83
cd example-site
npm run dev