fxpio / foxy

A fast, reliable, and secure NPM/Yarn/pnpm bridge for Composer
https://foxypkg.com
MIT License
173 stars 21 forks source link

Add support for the old versions of NPM <5.0 #24

Closed hiqsol closed 5 years ago

hiqsol commented 5 years ago

I get this error when running composer update (with foxy):

Updating npm dependencies
npm ERR! Linux 4.4.0-72-generic
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "update"
npm ERR! node v4.2.6
npm ERR! npm  v3.5.2

npm ERR! Cannot read property 'version' of undefined
npm ERR! 
npm ERR! If you need help, you may report this error at:
npm ERR!     <https://github.com/npm/npm/issues>

npm ERR! Please include the following file with any support request:
npm ERR!     /home/sol/prj/yiisoft/yii-twig/npm-debug.log
Fallback to previous state for the Asset package

When I run npm update directly I receive no error.

What could it be? Thank you in advance!

schmunk42 commented 5 years ago

Can you post the composer.json you're running the update with?

Although if npm works directly, you're also running with node 4, which reached its EOL https://github.com/nodejs/Release#release-schedule

hiqsol commented 5 years ago

It's yii-twig package. (fixed tests there)

When I run composer update with empty or removed node_modules dir it works fine. But after running composer update for second time I get this error.

terabytesoftw commented 5 years ago

Same mistake

Reading package.json
Merging Composer dependencies in the asset package
Updating npm dependencies
Executing command (CWD): npm update
npm ERR! Linux 3.10.0-862.11.6.el7.x86_64
npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "update"
npm ERR! node v6.14.3
npm ERR! npm  v3.10.10

npm ERR! Cannot read property 'version' of undefined
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR!     <https://github.com/npm/npm/issues>
npm ERR! Linux 3.10.0-862.11.6.el7.x86_64
npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "update"
npm ERR! node v6.14.3
npm ERR! npm  v3.10.10

npm ERR! Cannot read property 'version' of undefined
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR!     <https://github.com/npm/npm/issues>

npm ERR! Please include the following file with any support request:
npm ERR!     /home/app.cjtterabyte.com/public_html/npm-debug.log
Fallback to previous state for the Asset package
Fallback to previous state for Composer

the problem is with npm, and usually in centos7 this npm v.3 configure foxy with yarn and it works perfect.

"config": {
    "foxy": {
        "enable-packages": {
            "*": true
        },
        "manager": "yarn"
    }    
},
francoispluchino commented 5 years ago

When I have deploped this plugin, I worked with the last version of NPM and Yarn, that is NPM v5.0. By default, I did not add the minimum version values for NPM or Yarn, but it is might be nice to add default values.

I can try to look at the problem to make it compatible with NPM less than v5, but in this case, I need a complete example (with the dependencies) of a composer file.

I don't have much time available at the moment, so I don't know when I could look at it, but if you have a PR to propose, to have the support quickly, do not hesitate ;-).

francoispluchino commented 5 years ago

Given that the NPM 5.0 has 2 years old, I just defined the compatible minimum versions of asset managers (>=5.0 for NPM and >=1.0 for Yarn).

Of course, if you want compatibility with NPM <5.0, you can create a PR for this. I close this issue.