Why do Node modules go into .staging folder?

后端 未结 8 1518
轮回少年
轮回少年 2021-01-01 08:41

I have an Electron app that I\'m trying to install node modules for. When I run npm install, it creates the node_modules folder but all the modules

相关标签:
8条回答
  • 2021-01-01 09:19

    If you're automatically installing node_modules using CI/CD you should check out npm ci. Also check out this Stackoverflow question.

    npm ci
    

    The documentation points out the differences between npm install and npm ci.

    • The project must have an existing package-lock.json or npm-shrinkwrap.json
    • If dependencies in the package lock do not match those in package.json, npm ci will exit with an error, instead of updating the package lock.
    • npm ci can only install entire projects at a time: individual dependencies cannot be added with this command.
    • If a node_modules is already present, it will be automatically removed before npm ci begins its install. This is nice, because it prevents having to do something like rm -rf node_modules.
    • It will never write to package.json or any of the package-locks: installs are essentially frozen.
    0 讨论(0)
  • 2021-01-01 09:20

    I faced similar issue and tried the above answers but it did'nt worked for me; I followed below steps to resolve this issue-

    1.npm audit

    By running npm audit I got list of pending packages to install-

    2.npm i packagename

    After installing one or two package one by one from list, I used

    3.npm install

    At this time the installation went smooth without any lag or hangup. Hope this help who is facing similar issue :).

    0 讨论(0)
  • 2021-01-01 09:28

    This only happens temporarily until the modules are downloaded and installed. Node seems to do this so it can place together common submodules from all the modules you are installing so it can better structure the node modules folder(mainly for windows users).

    If this is happening after an npm install finishes it is likely that there is something wrong with your node installation or something in the install failed.

    0 讨论(0)
  • 2021-01-01 09:31

    This worked for me I moved the project from C drive to other drive and ran the following commands take a backup of older node modules if you are running this and existing project

    npm clear cache --force
    npm update
    
    0 讨论(0)
  • 2021-01-01 09:37

    I was having 2 versions of node installed on my system. nodejs v4.2 and node v8.6

    I thought this could be conflicting, so I deleted nodejs v4.2 with following commands.

    sudo apt-get remove nodejs
    

    and linked the path with

    sudo ln -s /usr/bin/node /usr/bin/nodejs
    

    Again I ran npm install and it got fixed

    0 讨论(0)
  • 2021-01-01 09:40

    I was also facing the same issue, I tried the steps below:

    1. Delete package-lock.json
    2. Delete Node Modules folder
    3. Try installing it using below command (should be in open network)

      npm install
      

    Note: - ".staging" means, those dependencies are getting downloaded so for the temporary basis it keeps all those dependencies under ".staging" folder. Once all gets downloaded properly then it will showcase them under node_modules only.

    I hope this will work.

    0 讨论(0)
提交回复
热议问题