【发布时间】:2017-09-09 19:19:05
【问题描述】:
我正在尝试使用 npm 包“create-react-app”开始使用 WebStorm 的 react 项目。
我已经运行npm install -g create-react-app 来全局安装该软件包,并且可以通过命令行完美使用该软件包(即create-react-app <proj name>)。
但是,在 WebStorm 中创建项目并使用全局“create-react-app”包的路径(使用npm list -g 找到)时,我遇到了这个错误:
/usr/bin/node /usr/local/lib/node_modules/create-react-app/index.js .
/usr/local/lib/node_modules/create-react-app/createReactApp.js:589
.filter(file => !validFiles.includes(file));
^
TypeError: validFiles.includes is not a function
at /usr/local/lib/node_modules/create-react-
app/createReactApp.js:589:33
at Array.filter (native)
at isSafeToCreateProjectIn (/usr/local/lib/node_modules/create-
react-app/createReactApp.js:589:6)
at createApp (/usr/local/lib/node_modules/create-react-
app/createReactApp.js:147:8)
at Object.<anonymous> (/usr/local/lib/node_modules/create-react-
app/createReactApp.js:134:1)
at Module._compile (module.js:410:26)
at Object.Module._extensions..js (module.js:417:10)
at Module.load (module.js:344:32)
at Function.Module._load (module.js:301:12)
at Module.require (module.js:354:17)
Done
我是不是在某个时候出错了?
【问题讨论】:
-
你找到解决方案了吗?
-
是的,我通过将节点更新到 v6 解决了这个问题。原来 create-react-app 需要 v6 或更高版本,并且 WebStrorm 控制台没有输出此警告。
标签: node.js npm webstorm create-react-app