Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Installing an npm package without saving to package.json or lock files #93

Open
1 task
shreshthmohan opened this issue Jun 23, 2023 · 0 comments
Open
1 task

Comments

@shreshthmohan
Copy link
Owner

shreshthmohan commented Jun 23, 2023



  • TODO: This will still break if there's a conflict with other dependencies in package.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.

  1. Switch to my desired version of node:
nvm use v16
  1. Install the required package without saving
npm install --no-package-lock --no-save tailwindcss@^3.3.0
  1. Define a script in package.json and then run it:
"scripts": {
    "twdev": "tailwindcss -i ./tailwind/styles.css -o ./app/assets/stylesheets/tailwind.css --watch"
}
  1. 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>
@shreshthmohan shreshthmohan added the draft A blog post that is a draft label Jun 23, 2023
@shreshthmohan shreshthmohan changed the title Installing an npm package without affecting other dependencies Installing an npm package without saving to package.json or lock files Oct 27, 2023
@shreshthmohan shreshthmohan added status:published category:code and removed draft A blog post that is a draft labels Nov 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant