‘jquery’ is imported by jquery?commonjs-external, but could not be resolved – treating it as an external dependency

rollup.js打包错误在安装@rollup/plugin-commonjs之后出现:

'jquery' is imported by jquery?commonjs-external, but could not be resolved – treating it as an external dependency

还需要@rollup/plugin-node-resolve解决node_modules引入问题:

Install
Using npm:

npm install @rollup/plugin-node-resolve --save-dev

Usage
Create a rollup.config.js configuration file and import the plugin:

import { nodeResolve } from '@rollup/plugin-node-resolve';

export default {
  input: 'src/index.js',
  output: {
    dir: 'output',
    format: 'cjs'
  },
  plugins: [nodeResolve()]
};

参考文档:https://www.npmjs.com/package/@rollup/plugin-node-resolve

本条目发布于。属于科技分类。作者是

关于有个狸

2005年开始的一名站长,从事网站策划、运营,早期一批扎根阿里妈妈、Google Adsense的一员,目前司职前端与产品设计。

发表回复