question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

sed: no files given

See original GitHub issue

can’t npm run resolvevue

package.json:

"scripts": {
...
"resolvevue": "shx sed -i \"s/'vue'/'https://cdn.jsdelivr.net/npm/vue@2.6.10/dist/vue.esm.browser.js'/g\" dist/*.js"
}

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
nfischercommented, Dec 9, 2019

I think you need to escape the / characters in your replacement string, otherwise sed treats them as special delimiters. This behavior is consistent with unix sed:

# Failing to escape quotes in unix sed would fail like so:
sed -i "s/'vue'/'https://cccdn.jsdelivr.net/npm/vue@2.6.10/dist/vue.esm.browser.js'/g" dist/*.js
sed: -e expression #1, char 17: unknown option to `s'

You should escape the characters with a "" in the commandline like so:

# Escape '/' characters so sed doesn't treat them specially anymore:
shx sed -i "s/'vue'/'https:\/\/cdn.jsdelivr.net\/npm\/vue@2.6.10\/dist\/vue.esm.browser.js'/g" dist/*.js

# The same is necessary for unix sed:
sed -i "s/'vue'/'https:\/\/cdn.jsdelivr.net\/npm\/vue@2.6.10\/dist\/vue.esm.browser.js'/g" dist/*.js

To use this in a package.json, you need double \ so JSON passes a single \ onto shx:

{
  "scripts": {
    "resolvevue": "shx sed -i \"s/'vue'/'https:\\/\\/cdn.jsdelivr.net\\/npm\\/vue@2.6.10\\/dist\\/vue.esm.browser.js'/g\" dist/*.js"
  }
}
0reactions
viT-1commented, Dec 9, 2019

Yes! This (in package.json) works:

shx sed -i \"s/'vue'/'https:\\/\\/cdn.jsdelivr.net\\/npm\\/vue@2.6.10\\/dist\\/vue.esm.browser.js'/g\" dist/*.js

@nfischer Please, add this to documentation.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to use SED without a file with an env var? - Stack Overflow
I needed to do replacement without echoing (use in PS1 variable). this was helpful to me. – astreal. Feb 17, 2013 at 11:45...
Read more >
Passing regular files only to `sed -i` - Unix & Linux Stack ...
Is there a way to have sed ignore errors and continue processing files? Case 3. for file in $(find . -maxdepth 1 -type...
Read more >
sed: can't read : No such file or directory - Super User
In your case, you have the file /tmp/tmp.Q18p8BRYcc/steam engine.txt that contains a space and that breaks your command. Please consider using ...
Read more >
In-place file editing - GNU SED - learnbyexample
This chapter will discuss how to write back the changes to the input file(s) itself using the -i command line option. This option...
Read more >
Linux sed command help and examples - Computer Hope
(Note that sed counts lines continuously across all input files unless -i or -s ... If no addresses are given, then all lines...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found