- TODO: This will still break if there's a conflict with other
dependencies
inpackage.json
I recently ran into a problem where I needed a package, but the existing set of npm packages would break if I installed the one I needed. This is because they needed a different Node.js version.
So here's what I did.
- Switch to my desired version of node:
nvm use v16
- Install the required package without saving
npm install --no-package-lock --no-save tailwindcss@^3.3.0
- Define a script in
package.json
and then run it:
package.json
"scripts": {
"twdev": "tailwindcss -i ./tailwind/styles.css -o ./app/assets/stylesheets/tailwind.css --watch"
}
- As an additional step I could switch back to the node version they were using earlier in a shell script
# Make note of current node version
nvm ls
# Store that in a variable and switch to that with
nvm use <prev-node-version>