gulp build

时间:2017-06-09 22:14:53

标签: javascript node.js npm gulp

我尝试用gulp设置项目。我正在使用gulpfile.js,我在之前的许多项目中使用过,但现在我收到错误的BrowserslistError,如下所示:

{project_root}/node_modules/browserslist/index.js:38
throw new BrowserslistError(name);
^
BrowserslistError: Unknown browser query `var browserslist = require('./');`
at error ({project_root}/node_modules/browserslist/index.js:38:11)
at {project_root}/node_modules/browserslist/index.js:246:9
at Array.forEach (native)
at browserslist ({project_root}/node_modules/browserslist/index.js:214:13)
at cleanBrowsersList ({project_root}/node_modules/caniuse-api/dist/utils.js:56:59)
at setBrowserScope ({project_root}/node_modules/caniuse-api/dist/index.js:26:43)
at Object.<anonymous> ({project_root}/node_modules/caniuse-api/dist/index.js:88:1)
at Module._compile (module.js:569:30)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:503:32)

我尝试删除node_modules文件夹并重新安装npm但没有成功。

1 个答案:

答案 0 :(得分:1)

几天前我遇到了类似的问题。我在package.json

中缺少browserslist声明

尝试将此(或类似)添加到package.json:

...
"browserslist": [
    "last 2 versions",
    "android 4",
    "opera 12"
]
...