Our use-case for this: Copying a project into a docker container which doesn't have permissions to pull all of our packages. A rebuild is required. (And npm rebuild
seems to error on the node_modules
left by yarn
for some reason.)
possibly related: https://github.com/yarnpkg/yarn/issues/756
Occasionally I have issues after switching environments around that are solved by an npm rebuild
. It's one of the few tasks I still have to rely on npm for currently.
fyi, with
yarn --version
0.24.5
node -v
v8.1.2
npm -v
5.0.3
after
yarn add --dev node-sass ...
exec of
npm rebuild node-sass
fails with
> [email protected] install /dev/www/yarn-test/node_modules/node-sass
> node scripts/install.js
module.js:487
throw err;
^
Error: Cannot find module '/dev/www/yarn-test/node_modules/node-sass/scripts/install.js'
at Function.Module._resolveFilename (module.js:485:15)
at Function.Module._load (module.js:437:25)
at Function.Module.runMain (module.js:605:10)
at startup (bootstrap_node.js:158:16)
at bootstrap_node.js:575:3
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: `node scripts/install.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2017-06-15T17_14_17_946Z-debug.log
but checking, the file does exist
ls /dev/www/yarn-test/node_modules/node-sass/scripts/install.js
/dev/www/yarn-test/node_modules/node-sass/scripts/install.js
Closing in favor of #756.
@BYK please reopen this issue. The other issue resolves in context of node version changing. We need an actual rebuild package command for cross-platform considerations.
Agreed, as commented in #4750.
Yes, those are different requests. This should be reopened.
Is there a workaround?
Depends on what your core problem is -- there is no equivalent for npm rebuild
due to architecture changes, which is a use case a number of us have. The npm rebuild
due to node version changes fix is what -- possibly mistakenly -- lead to this issue being closed.
@BYK can we get confirmation that this issue won't be re-opened, and we should file a new one?
Is there a workaround?
Depends on what your core problem is
Looking at all the comments at the topic, I think something like most of people - I changed node version and needed to rebuild _node-sass_. I managed to do that by using yarn install --force
.
I have a docker image that I build in stages, first excluding dev dependencies; later installing and building tests (finally, if tests run, taking original node_modules for production.). For test install, I need to use npm rebuild sass
. Other than that, I could leave out npm from my image entirely...
I used npm rebuild --update-binary
to resolve my issues. It doesn't create a package-lock file either so it shouldn't interfere with yarn.
I recently upgraded from node 8.x to 10.x and I had to rebuild bcrypt
. I noticed that when I ran yarn
right away without --force
flag, it would still rebuild the said package (and a few others that also had to be built). The process lasted for about a minute.
Though afterwards when I tried to launch the application, it said that the bcrypt
package was still built against node 8.x. I tried doing yarn --force
but it didn't even seem to be rebuilding at all (as in, the whole process only took about a second, as opposed to taking almost a minute with regular rebuilding). I ran the application once again just to make sure, but as expected it returned the error about wrong node version.
Either way, I finally did npm rebuild --update-binary
which @fugroup suggested and it finally rebuilt the package against the correct node version.
@loziniak doesn't seem like yarn install --force
does anything. I had to rebuild the platform-folders module after upgrading my Node JS version, but couldn't find any way to do this using Yarn (only after I used npm rebuild
as @BobbyWibowo shows above did it work). Not sure why this issue and the "closed in favor of" issue are both closed.
For visibility, I found: https://github.com/yarnpkg/yarn/issues/5271, which is what I guess folks trying to use Yarn with xplat modules need to keep an eye on.
Most helpful comment
I used
npm rebuild --update-binary
to resolve my issues. It doesn't create a package-lock file either so it shouldn't interfere with yarn.