2

I want to install a list of packages from a simple text file (yes, package.json is what this was designed for)

my first approach was this:

npm i $(cat builder-dev-packages.txt) -g similar to this: docker rm $(docker ps -a -f status=exited -q)

But I'm still getting that command evaluated as an invalid tag name.

npm ERR! code EINVALIDTAGNAME ": Tags may not have any characters that encodeURIComponent encodes.

Do I need to run through my npm command with a while loop instead of evaluating the output of a cat statement? This script still provides the same error for each line in the txt file.

#!/bin/bash
filename='./builder/builder-dev-packages.txt'
echo Start
while read p; do 
    npm i $p --dry-run
done < $filename

Here is my .txt file:

atob
colors
comment-parser
del
gulp
gulp-autoprefixer
gulp-clean-css
gulp-concat
gulp-connect
gulp-filter
gulp-htmlmin
gulp-if
gulp-nodemon
gulp-rename
gulp-replace
gulp-rewrite-css
gulp-rtlcss
gulp-sass
gulp-sourcemaps
gulp-uglify-es
lazypipe
merge-stream
node-sass
pretty
yargs
Nate W
  • 25
  • 1
  • 6

1 Answers1

1

npm install accept a list of packages delimited by space, but you are passing it a list of packages delimited with new line, this is why you experience issues.

try the following

npm install -g $(cat builder-dev-packages.txt | tr "\n" " ")
Mr.
  • 9,429
  • 13
  • 58
  • 82