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

[BUG] npm init seems broken #2206

Closed
outloudvi opened this issue Nov 20, 2020 · 7 comments
Closed

[BUG] npm init seems broken #2206

outloudvi opened this issue Nov 20, 2020 · 7 comments
Labels
Bug thing that needs fixing Needs Triage needs review for next steps Release 7.x work is associated with a specific npm 7 release

Comments

@outloudvi
Copy link

Current Behavior:

$ npm init react-app my-app
npm ERR! Cannot set property flatOptions of [object Object] which has only a getter

Expected Behavior:

npm init should generate the app with the boilerplate.

Steps To Reproduce:

  1. Install npm 7.0.12
  2. Run npm init react-app my-app

Environment:

  • Distro: Arch Linux
  • Node: v15.2.1
  • npm: v7.0.12

Error log:

0 verbose cli [
0 verbose cli   '/usr/bin/node',
0 verbose cli   '/home/<username>/<npm-local-dir>/bin/npm',
0 verbose cli   'init',
0 verbose cli   'react-app',
0 verbose cli   'my-app'
0 verbose cli ]
1 info using npm@7.0.12
2 info using node@v15.2.1
3 timing config:load:defaults Completed in 1ms
4 timing config:load:file:/home/<username>/<npm-local-dir>/lib/node_modules/npm/npmrc Completed in 1ms
5 timing config:load:builtin Completed in 1ms
6 timing config:load:cli Completed in 1ms
7 timing config:load:env Completed in 0ms
8 timing config:load:file:/tmp/.npmrc Completed in 0ms
9 timing config:load:project Completed in 0ms
10 timing config:load:file:/home/<username>/.npmrc Completed in 1ms
11 timing config:load:user Completed in 1ms
12 timing config:load:file:/home/<username>/<npm-local-dir>/etc/npmrc Completed in 1ms
13 timing config:load:global Completed in 1ms
14 timing config:load:cafile Completed in 0ms
15 timing config:load:validate Completed in 0ms
16 timing config:load:setUserAgent Completed in 0ms
17 timing config:load:setEnvs Completed in 1ms
18 timing config:load Completed in 6ms
19 verbose npm-session a8b4abf4a30f6f60
20 timing npm:load Completed in 11ms
21 timing command:init Completed in 2ms
22 verbose stack TypeError: Cannot set property flatOptions of [object Object] which has only a getter
22 verbose stack     at init (/home/<username>/<npm-local-dir>/lib/node_modules/npm/lib/init.js:46:21)
22 verbose stack     at cmd (/home/<username>/<npm-local-dir>/lib/node_modules/npm/lib/init.js:18:27)
22 verbose stack     at Object.[_runCmd] (/home/<username>/<npm-local-dir>/lib/node_modules/npm/lib/npm.js:118:7)
22 verbose stack     at fn (/home/<username>/<npm-local-dir>/lib/node_modules/npm/lib/npm.js:45:40)
22 verbose stack     at Object.<anonymous> (/home/<username>/<npm-local-dir>/lib/node_modules/npm/lib/cli.js:58:7)
23 verbose cwd /tmp
24 verbose Linux 5.9.9-arch1-1
25 verbose argv "/usr/bin/node" "/home/<username>/<npm-local-dir>/bin/npm" "init" "react-app" "my-app"
26 verbose node v15.2.1
27 verbose npm  v7.0.12
28 error Cannot set property flatOptions of [object Object] which has only a getter
29 verbose exit 1
@outloudvi outloudvi added Bug thing that needs fixing Needs Triage needs review for next steps Release 7.x work is associated with a specific npm 7 release labels Nov 20, 2020
@p3javier
Copy link

Hello @outloudvi

This only happens when you want to initialize with react-app or with other npm packages too?

@outloudvi
Copy link
Author

This only happens when you want to initialize with react-app or with other npm packages too?

@p3javier I've tried react-app, wasm-app, elm-app and they all give this.

@p3javier
Copy link

p3javier commented Nov 20, 2020

@outloudvi I think that the issue is related with this commit 39ad1ad#diff-d5109920b34c2b2e141bd41232d8876432a17479c388e142d8a036bb7b36ea62

Could you make a fresh install of the version npm@7.0.4 instead of npm@7.0.12 ?

@outloudvi
Copy link
Author

Could you make a fresh install of the version 7.0.4 instead of 7.0.12 ?

@p3javier Hi, I can confirm that npm@7.0.4 works for react-app and wasm-app.

@p3javier
Copy link

Could you make a fresh install of the version 7.0.4 instead of 7.0.12 ?

@p3javier Hi, I can confirm that npm@7.0.4 works for react-app and wasm-app.

So it seems that we catch the error! I will open a PR to review the changes made to anything that involves flatOptions between versions.

@ljharb
Copy link
Contributor

ljharb commented Nov 20, 2020

There’s no need to open a PR to compare commits between tags.

Since you’re saying v7.0.4 is fine, and v7.0.12 is not, perhaps you could do a binary search and determine in exactly which version it broke?

ruyadorno added a commit to ruyadorno/cli that referenced this issue Nov 20, 2020
The `flatOptions` property exposed by `lib/npm.js` should not be
redefined. This fixes an error in `npm init` by just avoiding trying to
override the property there.

Fixes: npm#2206
@nlf nlf mentioned this issue Nov 20, 2020
@nlf nlf closed this as completed in a0adbf9 Nov 20, 2020
@ruyadorno
Copy link
Contributor

Thanks @ljharb for the help here and @p3javier for tracking down this bug. It should be fixed in 7.0.13 😊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug thing that needs fixing Needs Triage needs review for next steps Release 7.x work is associated with a specific npm 7 release
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants