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

Node.js 8.0.0+ compatibility issue #287

Closed
kireerik opened this issue Jun 2, 2017 · 26 comments
Closed

Node.js 8.0.0+ compatibility issue #287

kireerik opened this issue Jun 2, 2017 · 26 comments

Comments

@kireerik
Copy link
Contributor

kireerik commented Jun 2, 2017

I have installed Node.js 8.0.0 under Windows 10 and I am getting the following errors when I am using the razzle start command:

\node_modules\razzle\config\create-config.js:60
        process.env.NODE_PATH.split(path.delimiter).filter(Boolean)
                             ^

TypeError: Cannot read property 'split' of undefined
    at module.exports (\node_modules\razzle\config\create-config.js:60:30)
    at Object.<anonymous> (\node_modules\razzle\scripts\start.js:35:20)
    at Module._compile (module.js:569:30)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:503:32)
    at tryModuleLoad (module.js:466:12)
    at Function.Module._load (module.js:458:3)
    at Function.Module.runMain (module.js:605:10)
    at startup (bootstrap_node.js:158:16)
    at bootstrap_node.js:575:3
\node_modules\execa\index.js:277
                throw (result.error || new Error(result.stderr === '' ? result.stdout : result.stderr));
                ^

Error: null
    at Function.module.exports.sync (\node_modules\execa\index.js:277:26)
    at Object.<anonymous> (\node_modules\razzle\bin\razzle.js:12:9)
    at Module._compile (module.js:569:30)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:503:32)
    at tryModuleLoad (module.js:466:12)
    at Function.Module._load (module.js:458:3)
    at Function.Module.runMain (module.js:605:10)
    at startup (bootstrap_node.js:158:16)
    at bootstrap_node.js:575:3
error Command failed with exit code 1.

I am getting a similar error for razzle build as well.

With Node.js 7.10.0 it worked and it still works if I install it back.

@jaredpalmer
Copy link
Owner

This line comes directly from https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/config/webpack.config.dev.js#L89

Can you try the latest create-react-app to see if you have the same issue?

@kireerik
Copy link
Contributor Author

kireerik commented Jun 2, 2017

I see.

Sure, now I have tested it and create-react-app works with both versions of Node.js.

@kireerik
Copy link
Contributor Author

kireerik commented Jun 2, 2017

Also I have used create-react-app as a global module, but I always use razzle as a local module.

@jaredpalmer
Copy link
Owner

I don't have a way to test this out unfortunately. I don't own a Windows PC. 😢

@kireerik
Copy link
Contributor Author

kireerik commented Jun 6, 2017

I see. So this issue doesn't occurs on your Mac?

It is possible to use Windows in a virtual box.

Running the following code using the Node.js console

console.log(process.env.NODE_PATH)

I am getting the following output:

undefined
undefined

Is this the expected behavior?

Also accourding to Razzle's source code it is not really possible that the process.env.NODE_PATH is undefined, because in this case it is set to ''.

@jaredpalmer
Copy link
Owner

hmm.. i'm just not seeing this.

screenshot 2017-06-06 18 37 51

@jaredpalmer
Copy link
Owner

Just tested, that in create-react-app process.env.NODE_PATH is undefined.

@kireerik
Copy link
Contributor Author

kireerik commented Jun 6, 2017

So you have the same issue with create-react-app, but not with Razzle?

@jaredpalmer
Copy link
Owner

@kireerik
Copy link
Contributor Author

kireerik commented Jun 7, 2017

I see.

In env.js it is definitely ''.

Interestingly if I console log it in create-config.js like this:

console.log(process.env.NODE_PATH)

Than I get this result:

$ razzle start
 WAIT  Compiling...

undefined
undefined
 DONE  Compiled successfully
...

So the server starts successfully.

Do you think I should report this issue at @facebookincubator's create-react-app as well?

@jaredpalmer
Copy link
Owner

Yes

@kireerik
Copy link
Contributor Author

kireerik commented Jun 7, 2017

Well, create-react-app now works for me with Node.js 8.

@kireerik kireerik changed the title Node.js 8.0.0 compatibility issue Node.js 8.0.0+ compatibility issue Jun 14, 2017
@gaearon
Copy link

gaearon commented Jun 28, 2017

Maybe code using NODE_PATH runs earlier than its initialization gets a chance to run?
We used to have an issue like this.

@jaredpalmer
Copy link
Owner

@kireerik What happens if you set NODE_PATH in your npm scripts?

{
  ...
  "scripts": {
      "start": "NODE_PATH=src razzle start",
      "test": "NODE_PATH=src razzle test",
       ...
   }
}

@kireerik
Copy link
Contributor Author

It works that way if I do it correctly like this: cross-env NODE_PATH=src razzle start

@jaredpalmer
Copy link
Owner

@gaearon does CRA use cross-env under the hood?

@kireerik
Copy link
Contributor Author

set NODE_PATH=src && razzle start works as well. (and I use src exacty)

@gaearon
Copy link

gaearon commented Jun 28, 2017

@jaredpalmer No (it doesn't launch processes for build/start unless I misunderstand something). We assing NODE_ENV ourselves depending on script, and ignore what the user set.

@sumankundu220
Copy link

replace NODE_PATH with PATH like
process.env.PATH

@paOol
Copy link

paOol commented Aug 10, 2017

same issues here

npm start

> my-razzle-app@0.1.0 start C:\web\frab
> razzle start

 WAIT  Compiling...

C:\web\frab\node_modules\razzle\config\createConfig.js:60
        process.env.NODE_PATH.split(path.delimiter).filter(Boolean)
                             ^

TypeError: Cannot read property 'split' of undefined
    at module.exports (C:\web\frab\node_modules\razzle\config\createConfig.js:60:30)
    at Object.<anonymous> (C:\web\frab\node_modules\razzle\scripts\start.js:34:20)
    at Module._compile (module.js:569:30)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:503:32)
    at tryModuleLoad (module.js:466:12)
    at Function.Module._load (module.js:458:3)
    at Function.Module.runMain (module.js:605:10)
    at startup (bootstrap_node.js:158:16)
    at bootstrap_node.js:575:3
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! my-razzle-app@0.1.0 start: `razzle start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the my-razzle-app@0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

@stoikerty
Copy link
Contributor

Looks like it's a race-condition, created a PR with the fix.

@kireerik
Copy link
Contributor Author

Thank you @stoikerty! I couldn't spot the root cause of this issue. It was so strange to me.

@jaredpalmer
Copy link
Owner

Wooo!!!

@jaredpalmer jaredpalmer reopened this Aug 25, 2017
@kireerik
Copy link
Contributor Author

Sorry, I thought this issue is resolved by now. At least it is working for me with the latest pre-release. Am I wrong with that?

@jaredpalmer
Copy link
Owner

Pressed the wrong button. ;)

@stereobooster
Copy link

Have the same issue. Only set NODE_PATH=src && razzle start worked for me

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

No branches or pull requests

7 participants