Cli: [BUG] npm init seems broken

Created on 20 Nov 2020  路  7Comments  路  Source: npm/cli

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 [email protected]
2 info using [email protected]
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
Bug Needs Triage Release 7.x

Most helpful comment

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

All 7 comments

Hello @outloudvi

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

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.

@outloudvi I think that the issue is related with this commit https://github.com/npm/cli/commit/39ad1ad9e1e1a9530db5b90a588b5081b71abc8d#diff-d5109920b34c2b2e141bd41232d8876432a17479c388e142d8a036bb7b36ea62

Could you make a fresh install of the version [email protected] instead of [email protected] ?

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

@p3javier Hi, I can confirm that [email protected] works for react-app and wasm-app.

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

@p3javier Hi, I can confirm that [email protected] 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.

There鈥檚 no need to open a PR to compare commits between tags.

Since you鈥檙e 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?

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jaydenseric picture jaydenseric  路  3Comments

ahuglajbclajep picture ahuglajbclajep  路  3Comments

DullReferenceException picture DullReferenceException  路  4Comments

dr-js picture dr-js  路  3Comments

darcyclarke picture darcyclarke  路  4Comments