Skip to content
This repository has been archived by the owner on Mar 1, 2024. It is now read-only.

npm install fails #383

Open
xanderdunn opened this issue Oct 22, 2021 · 5 comments
Open

npm install fails #383

xanderdunn opened this issue Oct 22, 2021 · 5 comments

Comments

@xanderdunn
Copy link

xanderdunn commented Oct 22, 2021

I've been attempting to run a testnet locally but I've been unable to npm install. macOS 11.6. npm 8.1.1. I'm on latest main, which is commit dcaa45a. I run:

$ npm cache clean --force
$ npm install

Full output here. A key line appears to be:

../src/addon.cpp:83:11: error: no matching member function for call to 'Set'
error                 target->Set(className, f);
error                 ~~~~~~~~^~~

I notice also it prints this:

1113 error gyp info find Python using Python version 3.9.7 found at "/opt/homebrew/opt/python@3.9/bin/python3.9"

Is there a dependency that's incompatible with Python 3.9? This may be a red herring.

I get the same error when I regenerate package-lock.json, clean, and attempt to install.

#54 is similar but I'm on npm 8 and the fix #55 is included in main now.

@xanderdunn
Copy link
Author

xanderdunn commented Oct 22, 2021

This might be a node version issue, rather than an npm version issue. I was on node 16.10.0, but it looks like this project may be using node v8.11.3. node v8 doesn't build on Apple Silicon. I might need to move this work to a Linux instance.

@xanderdunn
Copy link
Author

Starting over on an Ubuntu 18.04 machine and installing node 8.11.3 with nvm I've gotten npm install to work. It may be worth including in the README some of these dependencies:

  • node 8.11.3
  • python 2
  • Some C compiler, such as gcc
  • make
  • g++

@4lgn
Copy link

4lgn commented Jan 24, 2022

Starting over on an Ubuntu 18.04 machine and installing node 8.11.3 with nvm I've gotten npm install to work. It may be worth including in the README some of these dependencies:

  • node 8.11.3
  • python 2
  • Some C compiler, such as gcc
  • make
  • g++

Ran into the same problem, thanks for updating the issue with your experience.
I also support putting a few words in the README about such dependencies when they are as old as they are.

@7AC
Copy link

7AC commented Apr 27, 2022

Looks like it requires node 8, probably worth mentioning in the readme. The following worked for me:

docker run -v `pwd`:/contracts node:8 sh -c "cd contracts && npm install"
docker run -ti -v `pwd`:/contracts -p 9545:9545/tcp node:8 sh -c "cd contracts && npm run testrpc"

@DebasishBlockchain
Copy link

  1. Update Node.js and npm:
    Ensure you are using the latest versions of Node.js and npm. You mentioned you're on macOS 11.6, so make sure your Node.js and npm are up to date.

    You can update Node.js using a version manager like nvm or by downloading the latest version from the official Node.js website.

    To update npm, you can run:

    npm install -g npm@latest
    
  2. Verify Python Version:
    The error message indicates that Python 3.9.7 is being used. This version of Python should be compatible with most Node.js projects. However, you can try explicitly setting Python 2.7 as the target version just to check if it makes a difference:

    npm config set python /usr/bin/python2.7
    
  3. Check Package Dependencies:
    Review the project's package.json and package-lock.json files for any dependencies that might be causing conflicts. Sometimes, specific versions of packages may be incompatible with each other.

  4. Remove node_modules and Reinstall:
    Sometimes, the node_modules folder might be corrupted. Try removing it manually and then running npm install again:

    rm -rf node_modules
    npm install
    
  5. Check Node.js Compatibility:
    Verify that the project you're trying to build is compatible with the version of Node.js you're using. Some older projects may not be compatible with the latest versions of Node.js.

  6. Check Native Dependencies:
    The error message you mentioned is related to a native addon. Ensure that you have all the necessary build tools and dependencies installed on your system. On macOS, you can use Homebrew to install them:

    brew install node-gyp
    
  7. Environment Variables:
    Sometimes, environment variables can affect the build process. Ensure there are no conflicting environment variables related to Node.js or Python.

  8. Project-specific Issues:
    If the problem persists and is specific to the project you are trying to install, consider checking the project's GitHub repository for any open issues related to macOS or build problems. The project maintainers or contributors might have specific instructions or solutions.

After trying these steps, attempt to run npm install again.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants
@7AC @xanderdunn @4lgn @DebasishBlockchain and others