nodejs / snap

Node.js snap source and updater
MIT License
166 stars 38 forks source link

"npm init react-app my-app" indicates wrong (unsupported) version of node only when using the snap of version 16.15.1 #40

Open earthwormjim2 opened 2 years ago

earthwormjim2 commented 2 years ago

The result is that it creates an application with an old (unsupported) toolchain (which has a lot of security vulnerabilities). If I instead use the same version of node, packaged at nodesource: https://github.com/nodesource/distributions/blob/master/README.md it works fine.

My platform is Ubuntu 22.04.

Application Message follows:

"Note: the project was bootstrapped with an old unsupported version of tools. Please update to Node >=6 and npm >=3 to get supported tools in new projects."

rvagg commented 2 years ago

I think this is probably a dupe of https://github.com/nodejs/snap/issues/31, which I believe comes down to shelling out to node and not finding it properly in PATH because of the way Snaps do PATH manipulation. It's frustrating and the source of many problems, but I'm not really sure what to do about it. It'd be great to have someone dig deeper and figure out the actual root cause and see if there's any workaround we can implement to make child process calls more robust when called from within a Snap node.

KristijanZic commented 2 years ago

I get the same issue when executing create-react-app <my-app> --template typescript I get:

Note: the project was bootstrapped with an old unsupported version of tools.
Please update to Node >=14 and npm >=6 to get supported tools in new projects.

even tho:

$ node --version && npm --version
v16.17.0
8.17.0
rvagg commented 2 years ago

Do you have an older version of node on your system that's being masked by the newer one in the snap? maybe try removing that and the error might go away. Unfortunately so might your ability to run the command at all because it seems like it might be using that old version of Node to do the actual work.

Another thing you could try is manually "fixing" the PATH to provide a more direct route to the Snap node exe, something like: PATH=/snap/node/current/usr/bin/:$PATH create-react-app ... (I think /snap/node/current/usr/bin/ is right, I don't have a snap install handy to check, see if there's a node in that path, it'll be somewhere under /snap/node/current/ in a bin dir).