我似乎无法让我的脚本与Babel一起编译。我已经安装了 @ babel / polyfill
npm install --save @babel/polyfill
那给了我
babel /home/xxx/public_html/2018/js/lib/cat-ajax-scroll.js > /home/xxx/public_html/2018/js/lib-non-es6/cat-ajax-scroll.js
npm WARN deprecated core-js@2.6.11: core-js@<3 is no longer maintained and not recommended for usage due to the number of issues. Please, upgrade your dependencies to the actual version of core-js@3.
npm WARN lib@1.0.0 No description
npm WARN lib@1.0.0 No repository field.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.11 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.11: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
+ @babel/polyfill@7.7.0
updated 1 package and audited 6852 packages in 4.279s
然后,当我查看node_modules文件夹时,我正确地看到/ js / lib / node_modules / @ babel / polyfill中的所有文件
我的 .bablerc 如下:
{
"plugins": [
"babel-plugin-transform-es2015-template-literals",
"babel-plugin-transform-es2015-arrow-functions",
"@babel/polyfill"
]
}
但是当我运行编译器时,我得到了:
Error: Cannot find module '@babel/plugin-polyfill' from '/home/xxx/public_html/2018/js/lib'
- If you want to resolve "@babel/polyfill", use "module:@babel/polyfill"
at Function.module.exports [as sync] (/usr/lib/node_modules/@babel/core/node_modules/resolve/lib/sync.js:74:15)
at resolveStandardizedName (/usr/lib/node_modules/@babel/core/lib/config/files/plugins.js:101:31)
at resolvePlugin (/usr/lib/node_modules/@babel/core/lib/config/files/plugins.js:54:10)
at loadPlugin (/usr/lib/node_modules/@babel/core/lib/config/files/plugins.js:62:20)
at createDescriptor (/usr/lib/node_modules/@babel/core/lib/config/config-descriptors.js:154:9)
at /usr/lib/node_modules/@babel/core/lib/config/config-descriptors.js:109:50
at Array.map (<anonymous>)
at createDescriptors (/usr/lib/node_modules/@babel/core/lib/config/config-descriptors.js:109:29)
at createPluginDescriptors (/usr/lib/node_modules/@babel/core/lib/config/config-descriptors.js:105:10)
at plugins (/usr/lib/node_modules/@babel/core/lib/config/config-descriptors.js:40:19) {
code: 'MODULE_NOT_FOUND'
我不确定还能尝试什么:/