我正在尝试从Debian chroot中的源代码构建lumo(Clojurescript REPL),并遇到错误:
Building production bundle...
Circular dependency: src/js/cljs.js -> src/js/repl.js -> src/js/cljs.js
Circular dependency: src/js/cli.js -> src/js/cljs.js -> src/js/repl.js -> src/js/socketRepl.js -> src/js/cli.js
Circular dependency: src/js/repl.js -> src/js/socketRepl.js -> src/js/repl.js
Circular dependency: src/js/cljs.js -> src/js/repl.js -> src/js/socketRepl.js -> src/js/cljs.js
internal/modules/cjs/loader.js:796
throw err;
^
Error: Cannot find module 'rollup'
Require stack:
- /root/tmp/lumo-1.10.1/scripts/bundleForeign.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:793:17)
at Function.Module._load (internal/modules/cjs/loader.js:686:27)
at Module.require (internal/modules/cjs/loader.js:848:19)
at require (internal/modules/cjs/helpers.js:74:18)
at Object.<anonymous> (/root/tmp/lumo-1.10.1/scripts/bundleForeign.js:1:16)
at Module._compile (internal/modules/cjs/loader.js:955:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:991:10)
at Module.load (internal/modules/cjs/loader.js:811:32)
at Function.Module._load (internal/modules/cjs/loader.js:723:14)
at Function.Module.runMain (internal/modules/cjs/loader.js:1043:10) {
code: 'MODULE_NOT_FOUND',
requireStack: [ '/root/tmp/lumo-1.10.1/scripts/bundleForeign.js' ]
}
我尝试了yarn add rollup
,npm install rollup
和npm install -g rollup
,但都没有帮助。
不幸的是,我对该构建系统了解不多,不知道下一步该怎么做。
有什么想法吗?
以下是构建脚本:https://gist.github.com/cellularmitosis/df87e0c962e184b8bd29c8a3f07f3db4
编辑:这是bundleForeign.js的内容:
const rollup = require('rollup').rollup;
const resolve = require('rollup-plugin-node-resolve');
const replace = require('rollup-plugin-replace');
const commonjs = require('rollup-plugin-commonjs');
rollup({
input: 'node_modules/google-closure-compiler-js/compile.js',
plugins: [
replace({
'process.env.NODE_ENV': JSON.stringify('production'),
}),
resolve({
mainFields: ['module', 'main', 'jsnext:main'],
}),
commonjs(),
],
})
.then(bundle => {
bundle.write({
format: 'cjs',
file: 'target/google-closure-compiler-js.js',
strict: false,
});
})
.catch(console.error);
EDIT2:也许这只是一个节点问题?
我刚刚创建了/tmp/foo.js:
const rollup = require('rollup').rollup;
并运行cd /tmp && node foo.js
,它会产生相同的错误:
internal/modules/cjs/loader.js:796
throw err;
^
Error: Cannot find module 'rollup'
Require stack:
- /tmp/foo.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:793:17)
at Function.Module._load (internal/modules/cjs/loader.js:686:27)
at Module.require (internal/modules/cjs/loader.js:848:19)
at require (internal/modules/cjs/helpers.js:74:18)
at Object.<anonymous> (/tmp/foo.js:1:16)
at Module._compile (internal/modules/cjs/loader.js:955:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:991:10)
at Module.load (internal/modules/cjs/loader.js:811:32)
at Function.Module._load (internal/modules/cjs/loader.js:723:14)
at Function.Module.runMain (internal/modules/cjs/loader.js:1043:10) {
code: 'MODULE_NOT_FOUND',
requireStack: [ '/tmp/foo.js' ]
}
我尝试了npm install -g rollup
,但没有帮助。也许节点没有在正确的位置寻找全局模块?
答案 0 :(得分:1)
好吧,我觉得很愚蠢。
$ export NODE_PATH=/opt/node-v12.14.1-linux-x64/lib/node_modules/
$ node foo.js
$ echo $?
$ 0
我只需要设置NODE_PATH。