node2nix icon indicating copy to clipboard operation
node2nix copied to clipboard

Fails trying to link executable while doing a `npm install`

Open paulvictor opened this issue 6 years ago • 2 comments

I am trying to use node2nix to build nativefier using node2nix, as a intermediate step with which I thought of building other web based applications(gmail, slack ...). I am using home-manager to manage all my packages in the config and so modified the generated default.nix and node-env.nix (its no more a set with 3 attrs but the derivation of the nodePackage). While trying to install, the build fails with

npm info it worked if it ends with ok npm verb cli [ '/nix/store/av48vw9bj89j9iz7736i1zyz6g2yzzs1-nodejs-10.12.0/bin/node', npm verb cli '/nix/store/av48vw9bj89j9iz7736i1zyz6g2yzzs1-nodejs-10.12.0/bin/npm', npm verb cli '-dd', npm verb cli '--offline', npm verb cli '--nodedir=/nix/store/jii1y9cvasbyrn8qccqp2p9sw167mdl3-node-sources', npm verb cli '--production', npm verb cli 'install' ] npm info using [email protected] npm info using [email protected] npm verb npm-session 1ca0ab8bf6cbe337 npm info lifecycle [email protected]~preinstall: [email protected] npm timing stage:loadCurrentTree Completed in 448ms npm timing stage:loadIdealTree:cloneCurrentTree Completed in 2ms npm timing stage:loadIdealTree:loadShrinkwrap Completed in 58ms npm timing stage:loadIdealTree:loadAllDepsIntoIdealTree Completed in 254ms npm timing stage:loadIdealTree Completed in 374ms npm timing stage:generateActionsToTake Completed in 22ms npm verb correctMkdir /build/.npm/_locks correctMkdir not in flight; initializing npm verb makeDirectory /build/.npm/_locks creation not in flight; initializing npm timing audit compress Completed in 5ms npm info audit Submitting payload of 5313bytes npm verb lock using /build/.npm/_locks/staging-79326044fbe75152.lock for /nix/store/cj7912mr3cysfg5cg1q99dzdzxsm0y14-node-nativefier-7.6.10/lib/node_modules/nativefier/node_modules/.staging npm verb unlock done using /build/.npm/_locks/staging-79326044fbe75152.lock for /nix/store/cj7912mr3cysfg5cg1q99dzdzxsm0y14-node-nativefier-7.6.10/lib/node_modules/nativefier/node_modules/.staging npm timing stage:executeActions Completed in 40ms npm timing stage:rollbackFailedOptional Completed in 0ms npm info linkStuff [email protected] npm verb linkBins [ { nativefier: 'lib/cli.js' }, npm verb linkBins '/nix/store/cj7912mr3cysfg5cg1q99dzdzxsm0y14-node-nativefier-7.6.10/lib/node_modules/.bin', npm verb linkBins false ] npm verb stack Error: ENOENT: no such file or directory, chmod '/nix/store/cj7912mr3cysfg5cg1q99dzdzxsm0y14-node-nativefier-7.6.10/lib/node_modules/nativefier/lib/cli.js' npm verb cwd /nix/store/cj7912mr3cysfg5cg1q99dzdzxsm0y14-node-nativefier-7.6.10/lib/node_modules/nativefier npm verb Linux 4.19.12 npm verb argv "/nix/store/av48vw9bj89j9iz7736i1zyz6g2yzzs1-nodejs-10.12.0/bin/node" "/nix/store/av48vw9bj89j9iz7736i1zyz6g2yzzs1-nodejs-10.12.0/bin/npm" "-dd" "--offline" "--nodedir=/nix/store/jii1y9cvasbyrn8qccqp2p9sw167mdl3-node-sources" "--production" "install" npm verb node v10.12.0 npm verb npm v6.4.1 npm ERR! path /nix/store/cj7912mr3cysfg5cg1q99dzdzxsm0y14-node-nativefier-7.6.10/lib/node_modules/nativefier/lib/cli.js npm ERR! code ENOENT npm ERR! errno -2 npm ERR! syscall chmod npm ERR! enoent ENOENT: no such file or directory, chmod '/nix/store/cj7912mr3cysfg5cg1q99dzdzxsm0y14-node-nativefier-7.6.10/lib/node_modules/nativefier/lib/cli.js' npm ERR! enoent This is related to npm not being able to find a file.

I can see from the package.json file that the npm script build is the one which generates the lib/cli.js (verfied by manually running npm run build ).

So 2 things,

  1. Why does npm install try to link something which is not there when I am just trying to install dependencies?
  2. How do I enable that extra step gulp build?

I am using nodejs-10.

Thanks

Paul

paulvictor avatar Jan 09 '19 10:01 paulvictor

I've figured out the issue. I had to do a gulp build after the npm install (with dev dependencies) which I didn't do in the previous step and then link the binaries. So wrote a postInstall hook for the same. Was wondering if the same can be incorporated in the install phase by adding a hook after the npm install but before the linking of executables?

paulvictor avatar Jan 29 '19 05:01 paulvictor

@paulvictor Do you mind explaining in more detail what you did which allowed the build to run? Currently, Im trying to build nativefier from the github repo (not npm) and I am getting a similar error. So far, ive tried overriding the prebuild and preInstall phases to include npm run build but it has had no effect on the build process

hqurve avatar Jul 20 '21 19:07 hqurve