运行yeoman生成器"Webapp“时,我在运行gulp服务时出错。为了获得更好的背景,以下是以下版本:
sw_vers && node -e 'console.log(process.platform, process.versions)'
ProductName: Mac OS X
ProductVersion: 10.11.3
BuildVersion: 15D21
darwin { http_parser: '2.6.0',
node: '5.2.0',
v8: '4.6.85.31',
uv: '1.7.5',
zlib: '1.2.8',
ares: '1.10.1-DEV',
icu: '56.1',
modules: '47',
openssl: '1.0.2e' }
node -v
v5.2.0
gulp -v
Requiring external module babel-register
CLI version 3.9.1
Local version 3.9.1最后,狼吞虎咽的服务错误:
gulp serve
Requiring external module babel-register
\node_modules/babel-core/lib/transformation/file/options/option-manager.js:372
throw new Error("Couldn't find preset " + JSON.stringify(val) + " relative to directory " + JSON.stringify(dirname));有没有人知道问题可能是什么,有什么建议吗?
以下是我尝试过的:
npm uninstall gulp
npm install gulp
//with global flag and not
npm install --save-dev gulp
//installing babel-register manually w/wo global flag and --save-dev
npm install babel-register
npm cache clean还阅读了其他几个有类似问题的帖子,但没有成功,其中一些内容如下:
发布于 2016-04-07 11:40:18
是的,在运行npm install --global gulp-cli之后,我运行了gulp -v
Failed to load external module babel-register
Requiring external module babel-core/register
CLI version 1.2.1
Local version 3.9.1然后,我将CLI版本更新为3.9.1 (与本地版本相同),但没有帮助。但是,当我将CLI版本降级到3.9.0时,它就启动了正确的工作,并且消息“未能加载外部模块babel-”不再显示。看来3.9.1是有问题的。运行:
npm install -g gulp@3.9.0希望它能帮到你。
发布于 2016-08-20 01:15:55
也许这个能帮上忙。
在项目中创建.babelrc,并放置如下:
{
"presets": [
"es2015"
]
}发布于 2016-09-18 07:51:50
我已经尝试过很多方法来解释上面的内容,包括
npm install --global gulp
npm install --save-dev gulp 用于安装gulp,但最终通过在命令下面运行找到了解决方案,这将gulp更改为phpStorm命令行上的gulp。
npm install -D babelhttps://stackoverflow.com/questions/35832739
复制相似问题