Rollup issue: resolve failed, mootools already loaded, must be run with ava?

删除回忆录丶 提交于 2020-01-06 18:03:31

问题


I'm having an error that makes absolutely no sense. I haven't run rollup -c in about an month and running it now is causing all sorts of mayhem.

1) mootools already loaded

Why on earth is mootools already loaded in the log of this error? What is using mootools?

2) How is rolllup triggering ava?

If you scroll all the way at the bottom, I keen getting this random issue complaining that the bin itself needs to be run with ava.

Test files must be run with the AVA CLI: `ava node_modules/.bin/rollup`

3) Apparently missing dependencies.

The script is complaining about babel-runtime, n, foreman which is odd because I installed all of these. Just to make sure.

4) I've changed the entry

I've cleared the entry file to not contain any dependencies itself and the same errors still happen.

Here's my config:

module.exports = {
  external: [],
  entry: './src/appProxypass/index.js',
  dest: './packages/proxypass-app/index.js',
  format: 'cjs',
  plugins: [
    require('rollup-plugin-commonjs')({
    }),
    require('rollup-plugin-babel')({
      babelrc: false,
      runtimeHelpers: true,
      // externalHelpers: true,
      'presets': [
        'es2015-rollup',
        'stage-2'
      ],
      'plugins': [
        'transform-runtime',
        'transform-async-to-generator',
        'syntax-async-functions',
        'transform-flow-strip-types',
        'transform-class-properties'
      ],
      exclude: 'node_modules/**'
    }),
    require('rollup-plugin-cleanup')()
  ]
}

Here's my errors:

> rollup -c

resolve failed:  { Error: Cannot find module 'n'
    at Function.Module._resolveFilename (module.js:472:15)
    at Function.requireRelative.resolve (/Users/thomasreggi/Desktop/PAS/PAS-api/node_modules/babel-preset-es2015-rollup/node_modules/modify-babel-preset/node_modules/require-relative/index.js:30:17)
    at resolve (/Users/thomasreggi/Desktop/PAS/PAS-api/node_modules/babel-preset-es2015-rollup/node_modules/modify-babel-preset/lib/serialize.js:25:26)
    at findAndRemove (/Users/thomasreggi/Desktop/PAS/PAS-api/node_modules/babel-preset-es2015-rollup/node_modules/modify-babel-preset/lib/serialize.js:67:11)
    at /Users/thomasreggi/Desktop/PAS/PAS-api/node_modules/babel-preset-es2015-rollup/node_modules/modify-babel-preset/lib/serialize.js:111:13
    at Array.map (native)
    at loadPreset (/Users/thomasreggi/Desktop/PAS/PAS-api/node_modules/babel-preset-es2015-rollup/node_modules/modify-babel-preset/lib/serialize.js:103:29)
    at module.exports (/Users/thomasreggi/Desktop/PAS/PAS-api/node_modules/babel-preset-es2015-rollup/node_modules/modify-babel-preset/index.js:97:19)
    at Object.<anonymous> (/Users/thomasreggi/Desktop/PAS/PAS-api/node_modules/babel-preset-es2015-rollup/index.js:3:18)
    at Module._compile (module.js:573:32)
    at Object.Module._extensions..js (module.js:582:10)
    at Module.load (module.js:490:32)
    at tryModuleLoad (module.js:449:12)
    at Function.Module._load (module.js:441:3)
    at Module.require (module.js:500:17)
    at require (internal/module.js:20:19)
    at /Users/thomasreggi/Desktop/PAS/PAS-api/node_modules/rollup-plugin-babel/node_modules/babel-core/lib/transformation/file/options/option-manager.js:302:17
    at Array.map (native)
    at OptionManager.resolvePresets (/Users/thomasreggi/Desktop/PAS/PAS-api/node_modules/rollup-plugin-babel/node_modules/babel-core/lib/transformation/file/options/option-manager.js:270:20)
    at OptionManager.mergePresets (/Users/thomasreggi/Desktop/PAS/PAS-api/node_modules/rollup-plugin-babel/node_modules/babel-core/lib/transformation/file/options/option-manager.js:259:10)
    at OptionManager.mergeOptions (/Users/thomasreggi/Desktop/PAS/PAS-api/node_modules/rollup-plugin-babel/node_modules/babel-core/lib/transformation/file/options/option-manager.js:244:14)
    at OptionManager.init (/Users/thomasreggi/Desktop/PAS/PAS-api/node_modules/rollup-plugin-babel/node_modules/babel-core/lib/transformation/file/options/option-manager.js:374:12) code: 'MODULE_NOT_FOUND' } n
mootools already loaded
resolve failed:  { Error: Cannot find module 'foreman'
    at Function.Module._resolveFilename (module.js:472:15)
    at Function.requireRelative.resolve (/Users/thomasreggi/Desktop/PAS/PAS-api/node_modules/babel-preset-es2015-rollup/node_modules/modify-babel-preset/node_modules/require-relative/index.js:30:17)
    at resolve (/Users/thomasreggi/Desktop/PAS/PAS-api/node_modules/babel-preset-es2015-rollup/node_modules/modify-babel-preset/lib/serialize.js:25:26)
    at findAndRemove (/Users/thomasreggi/Desktop/PAS/PAS-api/node_modules/babel-preset-es2015-rollup/node_modules/modify-babel-preset/lib/serialize.js:67:11)
    at /Users/thomasreggi/Desktop/PAS/PAS-api/node_modules/babel-preset-es2015-rollup/node_modules/modify-babel-preset/lib/serialize.js:111:13
    at Array.map (native)
    at loadPreset (/Users/thomasreggi/Desktop/PAS/PAS-api/node_modules/babel-preset-es2015-rollup/node_modules/modify-babel-preset/lib/serialize.js:103:29)
    at module.exports (/Users/thomasreggi/Desktop/PAS/PAS-api/node_modules/babel-preset-es2015-rollup/node_modules/modify-babel-preset/index.js:97:19)
    at Object.<anonymous> (/Users/thomasreggi/Desktop/PAS/PAS-api/node_modules/babel-preset-es2015-rollup/index.js:3:18)
    at Module._compile (module.js:573:32)
    at Object.Module._extensions..js (module.js:582:10)
    at Module.load (module.js:490:32)
    at tryModuleLoad (module.js:449:12)
    at Function.Module._load (module.js:441:3)
    at Module.require (module.js:500:17)
    at require (internal/module.js:20:19)
    at /Users/thomasreggi/Desktop/PAS/PAS-api/node_modules/rollup-plugin-babel/node_modules/babel-core/lib/transformation/file/options/option-manager.js:302:17
    at Array.map (native)
    at OptionManager.resolvePresets (/Users/thomasreggi/Desktop/PAS/PAS-api/node_modules/rollup-plugin-babel/node_modules/babel-core/lib/transformation/file/options/option-manager.js:270:20)
    at OptionManager.mergePresets (/Users/thomasreggi/Desktop/PAS/PAS-api/node_modules/rollup-plugin-babel/node_modules/babel-core/lib/transformation/file/options/option-manager.js:259:10)
    at OptionManager.mergeOptions (/Users/thomasreggi/Desktop/PAS/PAS-api/node_modules/rollup-plugin-babel/node_modules/babel-core/lib/transformation/file/options/option-manager.js:244:14)
    at OptionManager.init (/Users/thomasreggi/Desktop/PAS/PAS-api/node_modules/rollup-plugin-babel/node_modules/babel-core/lib/transformation/file/options/option-manager.js:374:12) code: 'MODULE_NOT_FOUND' } foreman
resolve failed:  { Error: Cannot find module 'babel-runtime'
    at Function.Module._resolveFilename (module.js:472:15)
    at Function.requireRelative.resolve (/Users/thomasreggi/Desktop/PAS/PAS-api/node_modules/babel-preset-es2015-rollup/node_modules/modify-babel-preset/node_modules/require-relative/index.js:30:17)
    at resolve (/Users/thomasreggi/Desktop/PAS/PAS-api/node_modules/babel-preset-es2015-rollup/node_modules/modify-babel-preset/lib/serialize.js:25:26)
    at findAndRemove (/Users/thomasreggi/Desktop/PAS/PAS-api/node_modules/babel-preset-es2015-rollup/node_modules/modify-babel-preset/lib/serialize.js:67:11)
    at /Users/thomasreggi/Desktop/PAS/PAS-api/node_modules/babel-preset-es2015-rollup/node_modules/modify-babel-preset/lib/serialize.js:111:13
    at Array.map (native)
    at loadPreset (/Users/thomasreggi/Desktop/PAS/PAS-api/node_modules/babel-preset-es2015-rollup/node_modules/modify-babel-preset/lib/serialize.js:103:29)
    at module.exports (/Users/thomasreggi/Desktop/PAS/PAS-api/node_modules/babel-preset-es2015-rollup/node_modules/modify-babel-preset/index.js:97:19)
    at Object.<anonymous> (/Users/thomasreggi/Desktop/PAS/PAS-api/node_modules/babel-preset-es2015-rollup/index.js:3:18)
    at Module._compile (module.js:573:32)
    at Object.Module._extensions..js (module.js:582:10)
    at Module.load (module.js:490:32)
    at tryModuleLoad (module.js:449:12)
    at Function.Module._load (module.js:441:3)
    at Module.require (module.js:500:17)
    at require (internal/module.js:20:19)
    at /Users/thomasreggi/Desktop/PAS/PAS-api/node_modules/rollup-plugin-babel/node_modules/babel-core/lib/transformation/file/options/option-manager.js:302:17
    at Array.map (native)
    at OptionManager.resolvePresets (/Users/thomasreggi/Desktop/PAS/PAS-api/node_modules/rollup-plugin-babel/node_modules/babel-core/lib/transformation/file/options/option-manager.js:270:20)
    at OptionManager.mergePresets (/Users/thomasreggi/Desktop/PAS/PAS-api/node_modules/rollup-plugin-babel/node_modules/babel-core/lib/transformation/file/options/option-manager.js:259:10)
    at OptionManager.mergeOptions (/Users/thomasreggi/Desktop/PAS/PAS-api/node_modules/rollup-plugin-babel/node_modules/babel-core/lib/transformation/file/options/option-manager.js:244:14)
    at OptionManager.init (/Users/thomasreggi/Desktop/PAS/PAS-api/node_modules/rollup-plugin-babel/node_modules/babel-core/lib/transformation/file/options/option-manager.js:374:12) code: 'MODULE_NOT_FOUND' } babel-runtime

Test files must be run with the AVA CLI:

    $ ava node_modules/.bin/rollup

回答1:


Issue has something to do with rollup-plugin-babel. I removed it, and I'm using rollup on the lib version (built) rather then the src.

module.exports = {
  external: [],
  entry: './lib/appProxypass/index.js',
  dest: './packages/proxypass-app/index.js',
  format: 'cjs',
  plugins: [
    require('rollup-plugin-commonjs')(),
    require('rollup-plugin-cleanup')()
  ]
}


来源:https://stackoverflow.com/questions/41748665/rollup-issue-resolve-failed-mootools-already-loaded-must-be-run-with-ava

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!