Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to install @lightning/sdk with NPM version 7 #134

Closed
jhderojasUVa opened this issue Oct 23, 2020 · 3 comments
Closed

Unable to install @lightning/sdk with NPM version 7 #134

jhderojasUVa opened this issue Oct 23, 2020 · 3 comments
Assignees

Comments

@jhderojasUVa
Copy link

jhderojasUVa commented Oct 23, 2020

Hi,

If you have npm version 7.0.2 (included on node 15) you are unable to install lightning/sdk because the post-install scripts fails:

 npm ERR! path /builds/lightning/applications/XXXXXXXXXXX/node_modules/@lightningjs/sdk
 npm ERR! command failed
 npm ERR! command sh -c node ./scripts/postinstall.js
 npm ERR! mkdir: path already exists: /builds/lightning/applications/XXXXXXXXXXX/node_modules/@lightningjs/sdk/support
 npm ERR! node:internal/validators:123
 npm ERR!     throw new ERR_INVALID_ARG_TYPE(name, 'string', value);
 npm ERR!     ^
 npm ERR! 
 npm ERR! TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined
 npm ERR!     at new NodeError (node:internal/errors:258:15)
 npm ERR!     at validateString (node:internal/validators:123:11)
 npm ERR!     at Object.join (node:path:1039:7)
 npm ERR!     at Object.<anonymous> (/builds/lightning/applications/XXXXXXXXXXX/node_modules/@lightningjs/sdk/scripts/postinstall.js:61:34)
 npm ERR!     at Module._compile (node:internal/modules/cjs/loader:1083:30)
 npm ERR!     at Object.Module._extensions..js (node:internal/modules/cjs/loader:1112:10)
 npm ERR!     at Module.load (node:internal/modules/cjs/loader:948:32)
 npm ERR!     at Function.Module._load (node:internal/modules/cjs/loader:789:14)
 npm ERR!     at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:72:12)
 npm ERR!     at node:internal/main/run_main_module:17:47 {
 npm ERR!   code: 'ERR_INVALID_ARG_TYPE'
 npm ERR! }

This error shows that the line that is failing is:

const packageJson = require(path.join(process.env.INIT_CWD, 'package.json'))

Because the process.env.INIT_CWD returns undefined on npm 7.0.2

If you change the npm version to something below it will work with no problem.

You can reproduce the problem by creating a simple js file and run it as script on the package.json file (in order to make it run with the npm). For example

javascript.js

console.log(process.env.INIT_CWD)

package.json

.... THE NORMAL THINGS
"scripts": { "runme": "node ./javascript.js" }
.... THE NORMAL THINGS

And then run: npm run runme

This will shout you on the shell/bash/what you use: undefined

With other versions on npm will show the path of where the npm is called (the normal behaviour).

@michielvandergeest michielvandergeest self-assigned this Oct 23, 2020
@michielvandergeest
Copy link
Contributor

Quick update on this: I can confirm the same behaviour with npm@7.0.3 ..

In the mean time a bug report has been opened on the NPM github about INIT_CWD missing: npm/cli#2033. This is what ultimately is breaking things. So let's keep an eye on that one.

In the mean time I will apply an extra check for the existence of INIT_CWD to the SDK install script, so it won't error out.

@jhderojasUVa
Copy link
Author

The fix is working. Now it's time to wait until the official patch into npm or merge this :)

@michielvandergeest
Copy link
Contributor

Cool! Merged into the dev-branch. Will be released soon.

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

No branches or pull requests

2 participants