jeffposnick / create-react-pwa

https://github.com/facebookincubator/create-react-app + Progressive Web App goodness

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

npm run build failing on windows

jordaofranca opened this issue · comments

When I run "npm run build"

it fails on sw-precache --root='build/' --static-file-globs='build/_/!(_map)'

C:\Users\jordao.barroso\projects\teste-react>  "C:\Users\jordao.barroso\projects\teste-react\node_modules\.bin\\node.exe"  "C:\Users\jordao.barroso\projects\teste-react\node_modules\.bin\\..\sw-precache\cli.js" --root='build/' --static-file-globs='build/**/!(*map*)'

npm ERR! Windows_NT 6.1.7601
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "build"
npm ERR! node v6.4.0
npm ERR! npm  v3.10.3
npm ERR! code ELIFECYCLE
npm ERR! teste-react@0.0.1 build: `react-scripts build && cp manifest.json build/ && sw-precache --root='build/' --static-file-globs='build/**/!(*map*)'`
npm ERR! Exit status 255
npm ERR!
npm ERR! Failed at the teste-react@0.0.1 build script 'react-scripts build && cp manifest.json build/ && sw-precache --root='build/' --static-file-globs='build/**/!(*map*)''.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the teste-react package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     react-scripts build && cp manifest.json build/ && sw-precache --root='build/' --static-file-globs='build/**/!(*map*)'
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs teste-react
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls teste-react
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     C:\Users\jordao.barroso\projects\teste-react\npm-debug.log

but if i run "sw-precache --root='build/' --static-file-globs='build/_/!(_map)'" separately in cmd or git bash it works.

Does it fail the same way in both cmd and git bash? The output you're providing looks like it's from cmd.

I don't have a Windows machine handy to test, but I'll try when I can get my hands on one.

Same here. Same on bash (and cmd):

$ npm run-script build

> my-pwa@0.0.1 build C:\Projekty\nm-vagrant\netmoms-pwa
> react-scripts build && cp manifest.json build/ && sw-precache --root='build/' --static-file-globs='build/**/!(*map*)'

Creating an optimized production build...
Compiled successfully.

File sizes after gzip:

  47.15 KB  build\static\js\main.836cae05.js
  289 B     build\static\css\main.9a0fe4f1.css

The project was built assuming it is hosted at ./.
You can control this with the homepage field in your package.json.

The build folder is ready to be deployed.

' was unexpected at this time.

C:\Projekty\nm-vagrant\netmoms-pwa>  "C:\Projekty\nm-vagrant\netmoms-pwa\node_modules\.bin\\node.exe"  "C:\Projekty\nm-vagrant\netmoms-pwa\node_modules\.bin\\..\sw-precache\cli.js" --root='build/' --static-file-globs
='build/**/!(*map*)'

npm ERR! Windows_NT 10.0.14393
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\Dominik\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "run-script" "build"
npm ERR! node v4.4.1
npm ERR! npm  v3.10.8
npm ERR! code ELIFECYCLE
npm ERR! my-pwa@0.0.1 build: `react-scripts build && cp manifest.json build/ && sw-precache --root='build/' --static-file-globs='build/**/!(*map*)'`
npm ERR! Exit status 255
npm ERR!
npm ERR! Failed at the my-pwa@0.0.1 build script 'react-scripts build && cp manifest.json build/ && sw-precache --root='build/' --static-file-globs='build/**/!(*map*)''.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the my-pwa package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     react-scripts build && cp manifest.json build/ && sw-precache --root='build/' --static-file-globs='build/**/!(*map*)'
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs my-pwa
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls my-pwa
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     C:\Projekty\nm-vagrant\netmoms-pwa\npm-debug.log

Result - build folder created but no service worker inside it:
screenshot_4

Fixed issue on Windows using:
sw-precache-config.js

module.exports = {
  staticFileGlobs: [
    'build/static/**/!(*map*)',
    'build/index.html'
  ],
  stripPrefix: 'build/',
  runtimeCaching: []
};

And changing NPM scripts command to:
react-scripts build && cp manifest.json build/ && sw-precache --config=sw-precache-config.js --verbose

react-create-app changed the structure of files and folders. Index html was moved to public folder. Please change the configuration to the new structure mr. @jeffposnick .

G:\node\create-react-pwa-master>npm run-script build

> create-react-pwa@0.0.1 build G:\node\create-react-pwa-master
> react-scripts build && cp manifest.json build/ && sw-precache --root='build/'
--static-file-globs='build/**/!(*map*)'

Creating an optimized production build...
Compiled successfully.

File sizes after gzip:

  47.02 KB  build\static\js\main.07af1858.js
  289 B     build\static\css\main.9a0fe4f1.css

You can now publish them at ./.
For example, if you use GitHub Pages:

  git commit -am "Save local changes"
  git checkout -B gh-pages
  git add -f build
  git commit -am "Rebuild website"
  git filter-branch -f --prune-empty --subdirectory-filter build
  git push -f origin gh-pages
  git checkout -


'cp' is not recognized as an internal or external command,
operable program or batch file.

npm ERR! Windows_NT 10.0.10240
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\******\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "run-script" "build"
npm ERR! node v4.4.7
npm ERR! npm  v3.10.8
npm ERR! code ELIFECYCLE
npm ERR! create-react-pwa@0.0.1 build: `react-scripts build && cp manifest.json build/ && sw-precache --root='build/' --static-file-globs='build/**/!(*map*)'`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the create-react-pwa@0.0.1 build script 'react-scripts build && cp manifest.json build/ && sw-precache --root='build/' --static-file-globs='build/**/
!(*map*)''.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the create-react-pwa package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     react-scripts build && cp manifest.json build/ && sw-precache --root='build/' --static-file-globs='build/**/!(*map*)'
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs create-react-pwa
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls create-react-pwa
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     G:\node\create-react-pwa-master\npm-debug.log

G:\node\create-react-pwa-master>

Apologies about that. This project is unfortunately going to periodically get out of sync with create-react-app and its dependencies, but I will try to be more proactive about keeping it up to date.

I've got #7 open to track compatibility with the latest release on all platforms, but I'll leave this open to track Windows in particular, and make sure that it works in Windows after making the changes.

The solution mentioned by @dominikbulaj on also worked for me. Thanks!

I've updated things with an example of using the latest create-react-app dependency.

Can you take a look at c-r-a-0.6.0...c-r-pwa-0.6.0 and confirm that making those changes to something scaffolded with the latest create-react-app works for you?

I don't see any reason why it would not work on Windows, but I tend to be surprised by the little things that don't work as expected...

Thanks! I'll update that to remove the ''.

What do you mean by this ?

And changing NPM scripts command to:
react-scripts build && cp manifest.json build/ && sw-precache --config=sw-precache-config.js --verbose

The changes I made in build script is working in Windows . If ur not a Windows user than keep it as it is.