Skip to content

'module' object has no attribute 'script_main' #363

Closed

Description

@tj

all the addons are exploding for some reason:

> bcrypt@0.7.7 install /home/ubuntu/projects/api/node_modules/bcrypt
> node-gyp rebuild

Traceback (most recent call last):
  File "/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py", line 18, in <module>
    sys.exit(gyp.script_main())
AttributeError: 'module' object has no attribute 'script_main'
gyp ERR! configure error 
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:337:16)
gyp ERR! stack     at ChildProcess.EventEmitter.emit (events.js:98:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:789:12)
gyp ERR! System Linux 3.11.0-12-generic
gyp ERR! command "node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/ubuntu/projects/api/node_modules/bcrypt
gyp ERR! node -v v0.10.22
gyp ERR! node-gyp -v v0.12.1
gyp ERR! not ok 
npm ERR! bcrypt@0.7.7 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the bcrypt@0.7.7 install script.
npm ERR! This is most likely a problem with the bcrypt package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-gyp rebuild
npm ERR! You can get their info via:

version info:

node-gyp@0.12.1  /usr/local/lib/node_modules/node-gyp
node@0.10.22
python 2.7.5+

Activity

  1. TooTallNate commented on Dec 7, 2013

    @TooTallNate
    Contributor

    Hmmm, I haven't seen this. Seems like a borked gyp install somehow. Perhaps try re-installing?

  2. rex commented on Dec 8, 2013

    @rex

    I can confirm that this is a valid error, and we've tried reinstalling multiple times. Here is our log, running on an Amazon cloud instance:

    [root@tools ds]# npm install bcrypt
    npm WARN package.json expect.js@0.2.0 No repository field.
    info trying registry request attempt 1 at 19:10:26
    http GET https://registry.npmjs.org/bcrypt/0.7.4
    http 304 https://registry.npmjs.org/bcrypt/0.7.4
    info trying registry request attempt 1 at 19:10:27
    http GET https://registry.npmjs.org/bindings/1.0.0
    http 304 https://registry.npmjs.org/bindings/1.0.0
    
    > bcrypt@0.7.4 install /some/folder/node_modules/bcrypt
    > node-gyp rebuild
    
    Traceback (most recent call last):
      File "/usr/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py", line 18, in <module>
        sys.exit(gyp.script_main())
    AttributeError: 'module' object has no attribute 'script_main'
    gyp ERR! configure error
    gyp ERR! stack Error: `gyp` failed with exit code: 1
    gyp ERR! stack     at ChildProcess.onCpExit (/usr/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:337:16)
    gyp ERR! stack     at ChildProcess.EventEmitter.emit (events.js:98:17)
    gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:789:12)
    gyp ERR! System Linux 3.4.62-53.42.amzn1.x86_64
    gyp ERR! command "node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
    gyp ERR! cwd /some/folder/node_modules/bcrypt
    gyp ERR! node -v v0.10.21
    gyp ERR! node-gyp -v v0.12.1
    gyp ERR! not ok
    npm ERR! bcrypt@0.7.4 install: `node-gyp rebuild`
    npm ERR! Exit status 1
    npm ERR!
    npm ERR! Failed at the bcrypt@0.7.4 install script.
    npm ERR! This is most likely a problem with the bcrypt package,
    npm ERR! not with npm itself.
    npm ERR! Tell the author that this fails on your system:
    npm ERR!     node-gyp rebuild
    npm ERR! You can get their info via:
    npm ERR!     npm owner ls bcrypt
    npm ERR! There is likely additional logging output above.
    
    npm ERR! System Linux 3.4.62-53.42.amzn1.x86_64
    npm ERR! command "node" "/usr/bin/npm" "install" "bcrypt"
    npm ERR! cwd /some/folder
    npm ERR! node -v v0.10.21
    npm ERR! npm -v 1.3.15
    npm ERR! code ELIFECYCLE
    npm ERR!
    npm ERR! Additional logging details can be found in:
    npm ERR!     /some/folder/npm-debug.log
    npm ERR! not ok code 0
    
    

    Any ideas? :-/

  3. tj commented on Dec 8, 2013

    @tj
    Author

    probably just a funky package manager install, I'll try from source or sth tomorrow

  4. TooTallNate commented on Dec 8, 2013

    @TooTallNate
    Contributor

    @visionmedia Is this using the debian nodejs package or something?

  5. rex commented on Dec 9, 2013

    @rex

    @TooTallNate I'm sorry to keep intruding, but I just wanted to point out that the error I posted was generated by a server using Yum's EPEL package manager on a RedHat-based Amazon image, installed using yum install nodejs. Attempts to use the npm version of node-gyp were fruitless, as I believe that the yum-installed node-gyp is used by default. It is weird, though, because our other servers haven't had any issues with it. To be honest, we're not utilizing dependency version locking nearly as well as we should be (npm shrinkwrap et al), so this could very easily be a breaking change in the API of any one of those dependencies.

    That last part is purely speculation, of course, and not very helpful, but I wanted to provide as much feedback as possible.

    Edit: I am not sure how much it helps, if at all, but I noticed something weird when running npm -g list:

    npm ERR! invalid: inherits@2.0.0 /usr/lib/node_modules/inherits@2
    npm ERR! not ok code 0
    

    Subsequent attempts to npm -g update were not helpful. Though now that I'm thinking about it, I am not sure when last we cleared the npm cache. I'm going to try that and see what happens.

    Edit 2: Nope, npm cache clean didn't help. Even ran npm -g install inherits and it didn't fix the dependency bug. I am now completely in agreement with @visionmedia on this one, it seems to be a dependency bug somewhere. @TooTallNate if you need more info about the machine that created this error or anything else, please let me know so I can help get this resolved. :)

    Edit 3: For what it's worth, the server in question is running Python version 2.6.8.

  6. dready92 commented on Dec 9, 2013

    @dready92

    Hello,

    I got the exact same error trying to install libxmljs 0.8.1, on node 0.10.22 and python 2.7 on ubuntu 13.10.

    ~/.npm/libxmljs/0.8.1/package$ make
    node-gyp configure
    gyp info it worked if it ends with ok
    gyp info using node-gyp@0.12.1
    gyp info using node@0.10.22 | linux | x64
    gyp info spawn python
    gyp info spawn args [ '/home/mbailly/Documents/perso/node-0.10.22/lib/node_modules/node-gyp/gyp/gyp_main.py',
    gyp info spawn args   'binding.gyp',
    gyp info spawn args   '-f',
    gyp info spawn args   'make',
    gyp info spawn args   '-I',
    gyp info spawn args   '/home/mbailly/.npm/libxmljs/0.8.1/package/build/config.gypi',
    gyp info spawn args   '-I',
    gyp info spawn args   '/home/mbailly/Documents/perso/node-0.10.22/lib/node_modules/node-gyp/addon.gypi',
    gyp info spawn args   '-I',
    gyp info spawn args   '/home/mbailly/.node-gyp/0.10.22/common.gypi',
    gyp info spawn args   '-Dlibrary=shared_library',
    gyp info spawn args   '-Dvisibility=default',
    gyp info spawn args   '-Dnode_root_dir=/home/mbailly/.node-gyp/0.10.22',
    gyp info spawn args   '-Dmodule_root_dir=/home/mbailly/.npm/libxmljs/0.8.1/package',
    gyp info spawn args   '--depth=.',
    gyp info spawn args   '--generator-output',
    gyp info spawn args   'build',
    gyp info spawn args   '-Goutput_dir=.' ]
    Traceback (most recent call last):
      File "/home/mbailly/Documents/perso/node-0.10.22/lib/node_modules/node-gyp/gyp/gyp_main.py", line 18, in <module>
        sys.exit(gyp.script_main())
    AttributeError: 'module' object has no attribute 'script_main'
    gyp ERR! configure error 
    gyp ERR! stack Error: `gyp` failed with exit code: 1
    gyp ERR! stack     at ChildProcess.onCpExit (/home/mbailly/Documents/perso/node-0.10.22/lib/node_modules/node-gyp/lib/configure.js:337:16)
    gyp ERR! stack     at ChildProcess.EventEmitter.emit (events.js:98:17)
    gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:789:12)
    gyp ERR! System Linux 3.11.0-13-generic
    gyp ERR! command "node" "/home/mbailly/Documents/perso/node/bin/node-gyp" "configure"
    gyp ERR! cwd /home/mbailly/.npm/libxmljs/0.8.1/package
    gyp ERR! node -v v0.10.22
    gyp ERR! node-gyp -v v0.12.1
    gyp ERR! not ok 
    make: *** [build] Erreur 1
    

    Please help !

  7. tj commented on Dec 9, 2013

    @tj
    Author

    yeah the package manager ones seem pretty borked

  8. tj commented on Dec 9, 2013

    @tj
    Author

    yup re-install worked for me, so I guess just don't ever use the package managers haha

  9. laithshadeed commented on Dec 14, 2013

    @laithshadeed

    For me it got fixed by replacing python2.7 by python2.6. As per https://code.google.com/p/gyp/source/browse/trunk/DEPS#19 , it seems that gyp depends on python 2.6

    On Ubuntu Saucy:
    sudo add-apt-repository ppa:fkrull/deadsnakes
    sudo apt-get update
    sudo apt-get install python2.6
    sudo update-alternatives --install /usr/bin/python python /usr/bin/python2.6 20
    sudo update-alternatives --install /usr/bin/python python /usr/bin/python2.7 10

    you can switch between 2.6 & 2.7 using:
    sudo update-alternatives --config python

    Btw I installed node using ppa:chris-lea/node.js

    I hope this helps somebody.

  10. Lujaw commented on Dec 25, 2013

    @Lujaw

    @laithshadeed Thanks, it solved the issue for me..

  11. scottkellie commented on Jan 3, 2014

    @scottkellie

    @laithshadeed Also repaired my build on Linux mint 16 :) Thanks was driving me crazy!

  12. springmeyer commented on Jan 14, 2014

    @springmeyer

    Also just hit this on windows: in my case it was because I had a globally installed gyp version which was conflicting with the one inside node-gyp. I found my global install with python -c 'import gyp; print gyp.__file__' and removing it fixed the problem.

  13. matzoe commented on Jan 15, 2014

    @matzoe

    @springmeyer same to me. I just removed gyp to solve this problem.

  14. walidsynclio commented on Jan 17, 2014

    @walidsynclio

    I have installed node using sudo apt-get install nodejs
    suso apt-get install libexpat1-dev
    sudo npm install node-expat

    Same Issue

    root@abul-VirtualBox:~/node-xmpp-bosh# sudo npm install node-expat
    npm WARN package.json eventpipe@0.0.5 'repositories' (plural) Not supported.
    npm WARN package.json Please pick one as the 'repository' field
    npm WARN package.json jsdom@0.2.19 'repositories' (plural) Not supported.
    npm WARN package.json Please pick one as the 'repository' field
    npm WARN package.json node-lumberjack@0.0.4 'repositories' (plural) Not supported.
    npm WARN package.json Please pick one as the 'repository' field
    npm http GET https://registry.npmjs.org/node-expat
    npm http 304 https://registry.npmjs.org/node-expat
    
    > node-expat@2.0.0 install /root/node-xmpp-bosh/node_modules/node-expat
    > node-gyp rebuild
    
    Traceback (most recent call last):
      File "/usr/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py", line 18, in <module>
        sys.exit(gyp.script_main())
    AttributeError: 'module' object has no attribute 'script_main'
    gyp ERR! configure error 
    gyp ERR! stack Error: `gyp` failed with exit code: 1
    gyp ERR! stack     at ChildProcess.onCpExit (/usr/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:337:16)
    gyp ERR! stack     at ChildProcess.EventEmitter.emit (events.js:98:17)
    gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:789:12)
    gyp ERR! System Linux 3.5.0-17-generic
    gyp ERR! command "node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
    gyp ERR! cwd /root/node-xmpp-bosh/node_modules/node-expat
    gyp ERR! node -v v0.10.24
    gyp ERR! node-gyp -v v0.12.1
    gyp ERR! not ok 
    npm ERR! node-expat@2.0.0 install: `node-gyp rebuild`
    npm ERR! Exit status 1
    npm ERR! 
    npm ERR! Failed at the node-expat@2.0.0 install script.
    npm ERR! This is most likely a problem with the node-expat package,
    npm ERR! not with npm itself.
    npm ERR! Tell the author that this fails on your system:
    npm ERR!     node-gyp rebuild
    npm ERR! You can get their info via:
    npm ERR!     npm owner ls node-expat
    npm ERR! There is likely additional logging output above.
    
    npm ERR! System Linux 3.5.0-17-generic
    npm ERR! command "/usr/bin/node" "/usr/bin/npm" "install" "node-expat"
    npm ERR! cwd /root/node-xmpp-bosh
    npm ERR! node -v v0.10.24
    npm ERR! npm -v 1.3.21
    npm ERR! code ELIFECYCLE
    npm ERR! 
    npm ERR! Additional logging details can be found in:
    npm ERR!     /root/node-xmpp-bosh/npm-debug.log
    npm ERR! not ok code 0
    
  15. 20 remaining items

  16. juancancela commented on May 4, 2014

    @juancancela

    Im not able to resolve this issue in my configuration. Im using:

    *Centos 6.5
    *Python 2.6.6
    *Node 0.11.12-stable

    When trying npm install, im getting:

    gyp: /usr/local/bin/node/common.gypi not found (cwd: /opt/TeamCity/buildAgent/work/baca9f81a302b736/node_modules/tbx-commons-nodejs/node_modules/monk/node_modules/mongoskin/node_modules/mongodb/node_modules/bson) while reading includes of binding.gyp
    gyp ERR! configure error
    gyp ERR! stack Error: gyp failed with exit code: 1
    gyp ERR! stack at ChildProcess.onCpExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:337:16)
    gyp ERR! stack at ChildProcess.EventEmitter.emit (events.js:107:17)
    gyp ERR! stack at Process.ChildProcess._handle.onexit (child_process.js:1045:12)
    gyp ERR! System Linux 2.6.32-358.23.2.el6.x86_64
    gyp ERR! command "node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "configure" "build"
    gyp ERR! cwd /opt/TeamCity/buildAgent/work/baca9f81a302b736/node_modules/tbx-commons-nodejs/node_modules/monk/node_modules/mongoskin/node_modules/mongodb/node_modules/bson
    gyp ERR! node -v v0.11.12
    gyp ERR! node-gyp -v v0.12.2
    gyp ERR! not ok

    Already tried removing gyp python as suggested by @rex, but no luck. Any ideas?

    Thanks!

  17. tad-lispy commented on May 8, 2014

    @tad-lispy

    sudo apt-get remove gyp also worked for me on Linux Mint 16 AMD64 with Python 2.7.5+. Thanks to all of you :)

  18. compact commented on May 9, 2014

    @compact

    Similar to @lzrski's comment, in Fedora 20, yum remove gyp is a solution.

  19. gawen commented on May 19, 2014

    @gawen

    sudo apt-get remove gyp also worked for me on Linux 13.04 Python2.7. Thanks!

  20. JonathanPorta commented on May 19, 2014

    @JonathanPorta

    Renaming the python gyp module worked for me on my local machine. I am trying to deploy an app on Heroku, and running into the same problem. Unfortunately, I can't reach into Heroku's python modules, as far as I know. Has anyone ran into this, or have any suggestions?

  21. TooTallNate commented on May 19, 2014

    @TooTallNate
    Contributor

    Note that this should be fixed permanently (i.e. node-gyp will prefer its internal copy of gyp over a global one from a package manager) in node-gyp v0.13.1 due to 52e8d9f.

  22. carbohydrate commented on May 31, 2014

    @carbohydrate

    For future wonders, I was able to get atom to build on Fedora 20 by using what rex posted here. #363 (comment)
    python 2.7
    node -v 0.10.26
    npm -v 1.4.4
    I was running into problems building and installing spell-check0.35.0

  23. gdclarke commented on Jun 5, 2014

    @gdclarke

    this worked for me on Ubuntu 13.10 ...

    as suggested by @sheershoff sudo apt-get remove gyp

  24. hapees commented on Jun 10, 2014

    @hapees

    on Fedora 20:
    yum remove gyp
    did the job - thank you

  25. d0b1010r commented on Apr 16, 2015

    @d0b1010r

    Just had the same issue on an Amazon Elastic Beanstalk Instance (64bit Amazon Linux 2014.03 v1.1.0 running Node.js). Had installed globally via sudo yum install nodejs npm --enablerepo=epel as I needed bunyan to view logs. This borked up my deployments with the same error (AttributeError: 'module' object has no attribute 'script_main').

    Solved by running sudo yum remove gyp.noarch. Thanks guys!

    Beforehands, I tried to remove node via sudo yum remove nodejs npm --enablerepo=epel but this did not remove the gyp installation which affected the build.

  26. Jbudone commented on May 2, 2015

    @Jbudone

    Same problem on Amazon EC2, fixed w/ sudo npm -g install node-gyp

  27. darkoverlordofdata commented on May 4, 2015

    @darkoverlordofdata

    This worked on Mint 17, also. Thanks!!! I tried upgrading npm, node, switching py versions. It just shuffled the problem around. I thought I was going nuts. This fixed it:

    sudo apt-get remove gyp

  28. LogeshEswar commented on Sep 8, 2015

    @LogeshEswar

    while running codebox I got an following error Module did not self-register the i used the code node-gyp rebuild. Now its showing this error.

    gyp: binding.gyp not found (cwd: /home/logesh/code/megam/workspace/codebox) while trying to load binding.gyp
    gyp ERR! configure error
    gyp ERR! stack Error: gyp failed with exit code: 1
    gyp ERR! stack at ChildProcess.onCpExit (/usr/share/node-gyp/lib/configure.js:344:16)
    gyp ERR! stack at ChildProcess.EventEmitter.emit (events.js:98:17)
    gyp ERR! stack at Process.ChildProcess._handle.onexit (child_process.js:797:12)
    gyp ERR! System Linux 3.19.0-15-generic
    gyp ERR! command "nodejs" "/usr/bin/node-gyp" "rebuild"
    gyp ERR! cwd /home/logesh/code/megam/workspace/codebox
    gyp ERR! node -v v0.10.25
    gyp ERR! node-gyp -v v0.12.2
    gyp ERR! not ok
    logesh@logesh-Aspire-E1-431:/code/megam/workspace/codebox$ node -v
    v0.12.4
    logesh@logesh-Aspire-E1-431:
    /code/megam/workspace/codebox$ npm -v
    1.4.21

  29. added a commit that references this issue on Sep 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions