Cannot find module 'rollup'

On my production instance, when i do bench update. it gives following error

frappe@erpnext-production:~/frappe-bench$ bench build
yarn run v1.16.0
$ FRAPPE_ENV=production node rollup/build.js
module.js:487
    throw err;
    ^

Error: Cannot find module 'rollup'
    at Function.Module._resolveFilename (module.js:485:15)
    at Function.Module._load (module.js:437:25)
    at Module.require (module.js:513:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/home/frappe/frappe-bench/apps/frappe/rollup/build.js:4:16)
    at Module._compile (module.js:569:30)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:503:32)
    at tryModuleLoad (module.js:466:12)
    at Function.Module._load (module.js:458:3)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Note: I tried to follow all the suggestions present on discuss ex. [post1] (Error: Cannot find module ‘rollup’) but this solutions doesn’t work in my case.

My version:
Ubuntu 16.04.6 LTS
erpnext 11.1.30
frappe 11.1.28

Any help or clue is appreciated!!

try npm install rollup

Thanks! @saurabh6790 for your valuable input. I did make some progress. With every bench build it kept on throwing what was missing. So I ran following commands from bench folder

sudo npm install rollup
sudo npm install rollup-plugin-buble
sudo npm install rollup-plugin-uglify
sudo npm install rollup-plugin-vue

and finally bench build now gives below error!

/home/frappe/frappe-bench/node_modules/rollup-plugin-vue/dist/rollup-plugin-vue.js:118
        ...createVuePartRequest.defaultLang,
        ^^^

SyntaxError: Unexpected token ...

image

It is javascript error @netchampfaris any pointers are welcome! thanks

@ashish-greycube

Run bench setup requirements --node and it will download all required packages.

1 Like

Thanks! I tried but with no success
image

It seems you are running an older version of node. Please make sure your Node version is atleast 8.12.0

Check node version by running node -v

Thanks! @netchampfaris , i am able to make progress with above help but still not reached finishing lines.

nvm install 8.12.0

Then did bench build it throws other errors
Error: ENOENT: no such file or directory, open ‘/home/frappe/frappe-bench/apps/frappe/node_modules/moment/min/moment-with-locales.min.js’


It appears in frappe app node_module folder I don’t have all the required libraries

Question: What command should i run to have all the required node_modules in frappe folder so that build runs smoothly. Thanks!

@ashish-greycube

  1. Make sure you are running node version 8.12.0 or greater
  2. Change directory to frappe folder by running cd frappe-bench/apps/frappe
  3. Delete your node_modules folder in your frappe app folder by running rm -rf node_modules
  4. Change directory to frappe-bench folder by running cd ../..
  5. Run bench setup requirements --node
  6. Run bench build
7 Likes

Thanks!! @netchampfaris yes, it does solve the issue of having incorrect node_modules and bench build failing due to it.