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

replace-relative-paths error #2

Open
KushagraVasal opened this issue Jun 10, 2020 · 2 comments
Open

replace-relative-paths error #2

KushagraVasal opened this issue Jun 10, 2020 · 2 comments

Comments

@KushagraVasal
Copy link

KushagraVasal commented Jun 10, 2020

npm ERR! cordova-nuxt-demo@1.0.0 replace-relative-paths: replace '/nuxtfiles/' 'nuxtfiles/' dist --recursive && replace '/assets/' 'nuxtfiles/' dist --recursive && replace '(href|src|"href"|"src")="/' '$1="../' dist --recursive && replace '(href|src|"href"|"src"):"/' '$1:"../' dist --recursive

'src' is not recognized as an internal or external command,

@shirokovnv
Copy link

If you use windows terminal, you probably encounter these three errors:

  1. 'src' is not recognized as an internal or external command
    reason: some problems with parsing arguments from command line, probably
  2. cp command not found
    reason: windows terminal doesn't have such a command. Use copy or xcopy instead.
  3. rm command not found
    reason: no rm command in cmd. Use rmdir instead.

That's how I solved it:

  1. create new folder in project root, called scripts/
  2. create replace-relative-paths.js inside
var replace = require('replace');

replace({
    regex: '/nuxtfiles/',
    replacement: 'nuxtfiles/',
    paths: ['dist'],
    recursive: true,
    silent: true,
});

replace({
    regex: '/assets/',
    replacement: 'nuxtfiles/',
    paths: ['dist'],
    recursive: true,
    silent: true,
});

replace({
    regex: '(href|src|\"href\"|\"src\")=\"/',
    replacement: '$1=\"../',
    paths: ['dist'],
    recursive: true,
    silent: true,
});

replace({
    regex: '(href|src|\"href\"|\"src\"):\"/',
    replacement: '$1:\"../',
    paths: ['dist'],
    recursive: true,
    silent: true,
});
  1. in package.json add in scripts section:
"clear-cordova-win:: "rmdir /s/q cordova\\www && mkdir cordova\\www",
"copy-cordova-win": "xcopy /E /I /Y dist cordova\\www",
"cordova-win": "npm run build-spa && npm run replace-relative-paths && npm run copy-cordova-win && npm run run-android",

change replace-relative-paths key for:

"replace-relative-paths": "node ./scripts/replace-relative-paths",
  1. Run in terminal:
npm run cordova-win

Enjoy! :D

b.t.w. Thanks for the awesome nuxtjs-cordova template!

@filipefelice
Copy link

Wonderful!
Thanks @shirokovnv shirokovnv

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants