SAP / node-rfc

Asynchronous, non-blocking SAP NW RFC SDK bindings for Node.js
Apache License 2.0
252 stars 73 forks source link

npm install --only=prod #254

Closed phhoef closed 2 years ago

phhoef commented 2 years ago

Describe the bug When trying to install the dependency only with not devDependencies an error is raised. When only npm install is called, the installation is working.

root:/opt/test# npm install --only=prod
npm ERR! code 127
npm ERR! path /opt/test/node_modules/node-rfc
npm ERR! command failed
npm ERR! command sh -c prebuild-install -r napi || cmake-js rebuild
npm ERR! sh: 1: prebuild-install: not found
npm ERR! sh: 1: cmake-js: not found

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2022-03-31T10_25_06_456Z-debug.log

To Reproduce Create a new project with npm. Add node-rfc as dependency. Delete the node_modules folder and run npm install --only=prod

When adding the following two dependencies to my dependencies it is working:

Is this by design or should both dependencies moved from devDependencies to dependencies?

Environment

bsrdjan commented 2 years ago

Thanks for finding this bug and the solution.

Is this by design or should both dependencies moved from devDependencies to dependencies?

According to prebuild documentation, only prebuild-install is mandatory dependency, moreover at application level. The installation should therefore work like:

npm i --only=prod prebuild-install node-rfc  

or

package.json

  "dependencies": {
    "node-rfc": "^2.6.0",
    "prebuild-install": "^7.0.1"
  }

Could you please check it it works in your environment?

I would move only prebuild-install to dependencies (from dev dependencies) because cmake-js requires native CMake which can't be installed "on the fly", together with other dependencies.

Would it work for your scenario?

phhoef commented 2 years ago

Hallo @bsrdjan, thanks for your quick reply. I can confirm, that adding prebuild-install to the dependencies is sufficient.