Closed kireerik closed 7 years ago
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?
I see.
Sure, now I have tested it and create-react-app works with both versions of Node.js.
Also I have used create-react-app as a global module, but I always use razzle as a local module.
I don't have a way to test this out unfortunately. I don't own a Windows PC. 😢
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 ''
.
hmm.. i'm just not seeing this.
Just tested, that in create-react-app process.env.NODE_PATH
is undefined.
So you have the same issue with create-react-app, but not with Razzle?
Nope. They have identical behavior because the code that handles NODE_PATH is copied directly CRA
https://github.com/jaredpalmer/razzle/blob/master/packages/razzle/config/env.js#L46
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?
Yes
Well, create-react-app now works for me with Node.js 8.
Maybe code using NODE_PATH
runs earlier than its initialization gets a chance to run?
We used to have an issue like this.
@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",
...
}
}
It works that way if I do it correctly like this: cross-env NODE_PATH=src razzle start
@gaearon does CRA use cross-env under the hood?
set NODE_PATH=src && razzle start
works as well. (and I use src
exacty)
@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.
replace NODE_PATH with PATH like process.env.PATH
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.
Thank you @stoikerty! I couldn't spot the root cause of this issue. It was so strange to me.
Wooo!!!
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?
Pressed the wrong button. ;)
Have the same issue. Only set NODE_PATH=src && razzle start
worked for me
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: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.