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

Can't build with cross-env - Error: spawn webpack ENOENT #9

Closed
ktmn opened this issue Nov 11, 2015 · 7 comments
Closed

Can't build with cross-env - Error: spawn webpack ENOENT #9

ktmn opened this issue Nov 11, 2015 · 7 comments

Comments

@ktmn
Copy link

ktmn commented Nov 11, 2015

Cloned repo, ran install, ran start - works fine. Ran build - get this error:

λ npm run build

> react-toolbox-example@0.11.3 build C:\...\react-toolbox-example
> cross-env NODE_ENV=production UV_THREADPOOL_SIZE=100 webpack --config ./webpack.config.file

events.js:141
      throw er; // Unhandled 'error' event
      ^

Error: spawn webpack ENOENT
    at exports._errnoException (util.js:837:11)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:178:32)
    at onErrorNT (internal/child_process.js:344:16)
    at doNTCallback2 (node.js:429:9)
    at process._tickCallback (node.js:343:17)
    at Function.Module.runMain (module.js:477:11)
    at startup (node.js:117:18)
    at node.js:951:3

npm ERR! Windows_NT 10.0.10240

So I tried to set node env manually

SET NODE_ENV=production && webpack --config ./webpack.config.file

But it didn't work or something, because the built react-toolbox.js file will still look for __webpack_hmr EventSource, so hmr appears to be still enabled.

The problem also appears in my actual project, that I used react-toolbox in. I eliminated any trace of hmr from my source files yet it still kept showing up - turns out it was from the source of react-toolbox. So how do I let it know that the "node env" is "production"?

Also tried to do it in the webpack.config.file.js file

'process.env.NODE_ENV': JSON.stringify('production')

Nothing changed.

@javivelasco
Copy link
Member

That's weird. I noticed the HMR issue and added the production env variable to the script. Then, I made it work properly. As I said in other issues, I have no Windows machine and can't test it but the issue is clearly related to how env variables are set in a Windows env.

For now we need to set the production env variable to avoid including HMR and also to increase the thread pool to overcome a node-sass issue that makes the compilation freeze. It's important to have it working across different OS envs and I thought it was solved with the cross-env PR.

If anybody can help with the Windows support it would be very welcome!

@javivelasco
Copy link
Member

@NogsMPLS played a lot with this kind of issues, maybe he can help!

@NogsMPLS
Copy link
Contributor

Hey @ktmn I noticed this issue was created 4 days ago. This is right around the time that I had a PR get merged into the cross-env repo.

However, I don't know if you npm installed before or after that release for cross-env was tagged that day.

If possible, could you pull/fetch the latest from this repo and then npm install again and make sure in your node_modules folder that the cross-env package.json has 1.0.4 as the version number?

It should work, as the whole reason I put in the PR to cross-env was because I was getting ENOENT issues before as well.

SIDE NOTE: the current react-toolbox-example repo has npm scripts run against webpack.config.file but that doesn't exist anymore, so there is another error happening around that, i'll submit a PR here in a minute to change it to just webpack.config

@javivelasco
Copy link
Member

Great! @ktmn can you try it?

@ktmn
Copy link
Author

ktmn commented Nov 16, 2015

My bad I completely forgot to post here, but I resolved the issue by reinstalling react-toolbox. So basically, yes, what Nogs said. And now I understand why it actually worked. Thanks!

@ktmn ktmn closed this as completed Nov 16, 2015
@javivelasco
Copy link
Member

Great!

@Timodie
Copy link

Timodie commented Dec 17, 2018

I faced a similar issue and the fix was to make sure the fields of the WebpackPwaManifest matched that of your package.json

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

4 participants