ignite icon indicating copy to clipboard operation
ignite copied to clipboard

Error in create new app.

Open araymoises opened this issue 5 years ago • 28 comments

Error in create new app. Sin título

I'm new with Ignite, i want to create a new project and it gives me this error. Any solution?

Steps to reproduce

  1. npx ignite-cli new APP

araymoises avatar Mar 23 '21 23:03 araymoises

Might be the wrong issue, but do you have yarn installed? I had similar errors when my environment wasn't set up properly (I had wonky versions of Node via both NVM and Homebrew installed and it was confusing the system when I used npx).

Can you try making an expo project (like npx ignite-cli new PizzaApp --expo) and see if it still fails?

jvgeee avatar Mar 25 '21 02:03 jvgeee

I have exactly the same issue - actually had it 2 weeks ago and gave up with ignite, but trying again now in some spare time.

npx ignite-cli new ignited
   · · · · · · · · · · · · · · · · · · 🔥 Ignite 🔥 · · · · · · · · · · · · · · · · · ·

    █ Creating ignited using Ignite 6.6.0
    █ Powered by Infinite Red - https://infinite.red
    █ Using react-native-cli
    ────────────────────────────────────────────────

   🔥 Igniting app
   🖨  3D-printing a new React Native app
C:\Users\user\AppData\Roaming\npm-cache\_npx\3460\node_modules\ignite-cli\node_modules\gluegun\build\index.js:13
    throw up;
    ^

TypeError: Cannot read property 'replace' of undefined
    at C:\Users\user\AppData\Roaming\npm-cache\_npx\3460\node_modules\ignite-cli\build\commands\new.js:137:26
    at step (C:\Users\user\AppData\Roaming\npm-cache\_npx\3460\node_modules\ignite-cli\build\commands\new.js:44:23)
    at Object.next (C:\Users\user\AppData\Roaming\npm-cache\_npx\3460\node_modules\ignite-cli\build\commands\new.js:25:53)
    at fulfilled (C:\Users\user\AppData\Roaming\npm-cache\_npx\3460\node_modules\ignite-cli\build\commands\new.js:16:58)    at processTicksAndRejections (internal/process/task_queues.js:93:5)

Yes I have yarn:

> yarn -v
1.22.5

Does the same work with --expo ? yes:

> npx ignite-cli new ignited --expo
   · · · · · · · · · · · · · · · · · · 🔥 Ignite 🔥 · · · · · · · · · · · · · · · · · ·
    █ Creating ignited using Ignite 6.6.0
    █ Powered by Infinite Red - https://infinite.red
    █ Using expo-cli
    ────────────────────────────────────────────────
   🔥 Igniting app
   🪔 Summoning Expo CLI
   🎫 Cleaning up Expo install
   🧶 Unboxing NPM dependencies
   🗄  Backing everything up in source control
   Ignite CLI ignited ignited in 463.19s

   To get started:
     cd ignited
     yarn start

   Need additional help?

   Join our Slack community at http://community.infinite.red.

   Now get cooking! 🍽
   · · · · · · · · · · · · · · · · · · 🔥 Ignite 🔥 · · · · · · · · · · · · · · · · · ·

Then I removed my npx cache (i.e. where the error stack starts from) - C:\Users\user\AppData\Roaming\npm-cache_npx
Then try again without --expo:

> npx ignite-cli new ignited2

   · · · · · · · · · · · · · · · · · · 🔥 Ignite 🔥 · · · · · · · · · · · · · · · · · ·
    █ Creating ignited2 using Ignite 6.6.0
    █ Powered by Infinite Red - https://infinite.red
    █ Using react-native-cli
    ────────────────────────────────────────────────

   🔥 Igniting app
   🖨  3D-printing a new React Native app
C:\Users\user\AppData\Roaming\npm-cache\_npx\15508\node_modules\ignite-cli\node_modules\gluegun\build\index.js:13
    throw up;
    ^

TypeError: Cannot read property 'replace' of undefined
    at C:\Users\user\AppData\Roaming\npm-cache\_npx\15508\node_modules\ignite-cli\build\commands\new.js:137:26
    at step (C:\Users\user\AppData\Roaming\npm-cache\_npx\15508\node_modules\ignite-cli\build\commands\new.js:44:23)
    at Object.next (C:\Users\user\AppData\Roaming\npm-cache\_npx\15508\node_modules\ignite-cli\build\commands\new.js:25:53)
    at fulfilled (C:\Users\user\AppData\Roaming\npm-cache\_npx\15508\node_modules\ignite-cli\build\commands\new.js:16:58)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)

This is on Windows 10, node v14.6.0 npm/x v6.4.11

At the moment it seems ignite on Windows has got its matches wet !

PS - I also have an environment running that can already support react-native dev via react-native, Android Studio etc. So I'm assuming all the pre-reqs for ignite are in place, but I'm reviewing the "Setting up the development environment" tutorial to make sure.

andrewlorenz avatar Mar 26 '21 16:03 andrewlorenz

just having a dig in the code, and I can't actually make sense of the line numbers as its ts/compiled, but it must be this little snippet:

let packageJsonRaw = filesystem.read("package.json")
packageJsonRaw = packageJsonRaw
  .replace(/HelloWorld/g, projectName)
  .replace(/hello-world/g, projectNameKebab)
let packageJson = JSON.parse(packageJsonRaw)

but this code runs for both expo and true native, so the issue must be above these lines. So moving up the code, we have a ternary based on expo:

const cliString = expo
  ? `npx expo-cli init ${projectName} --template ${boilerplatePath} --non-interactive`
  : `npx react-native init ${projectName} --template file://${ignitePath}${
        debug ? " --verbose" : ""
    }`

So I imagine the issue is from here - the obvious assumption is that package.json is missing from the template.

And ... I can see there's a debug option!, so I've used it:

> npx ignite-cli new ignited2 --debug

and so the assumption is confirmed:

   🔥 Igniting app
npx react-native init ignited2 --template file://C:\Users\user\AppData\Roaming\npm-cache\_npx\15384\node_modules\ignite-cli --verbose
debug We couldn't find a package.json in your project. Are you sure you are running it inside a React Native project?

debug Failed to load configuration of your project. Only a subset of commands will be available.

debug Initializing new project

Hopefully someone with intimate knowledge of this repo can now take over and chase the issue down to a conclusion?

andrewlorenz avatar Mar 26 '21 17:03 andrewlorenz

seeing this:


   · · · · · · · · · · · · · · · · · · 🔥 Ignite 🔥 · · · · · · · · · · · · · · · · · ·

    █ Creating PizzaApp using Ignite 6.6.0
    █ Powered by Infinite Red - https://infinite.red
    █ Using react-native-cli
    ────────────────────────────────────────────────

   🔥 Igniting app
   🧊 Cooling print nozzles
   ☕️ Baking CocoaPods

/Users/xxx/.npm/_npx/e31027f3785124a8/node_modules/gluegun/build/index.js:13
    throw up;
    ^
yarn run v1.22.10
warning ../../../package.json: No license field
error Command "format" not found.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

hsavit1 avatar Mar 28 '21 16:03 hsavit1

FYI it worked when starting a new expo project

hsavit1 avatar Mar 28 '21 16:03 hsavit1

strange thing, I've now got past the first apparent debug error message - that there is no package.json - by not trying to install in a folder-name which contains an underscore (a known foible of react-native-cli), but I'm still getting the exact same error as before (just a little later down the process)!

   🖨  3D-printing a new React Native app
debug Installing template from file://C:\Programs\nvm\v14.16.0\node_modules\ignite-cli
yarn init v1.22.5
success Saved package.json
Done in 0.06s.
yarn add v1.22.5
info No lockfile found.
[1/4] Resolving packages...
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.
C:\www
C:\www\ignited\.gitignore
C:\Programs\nvm\v14.16.0\node_modules\ignite-cli\boilerplate\.npmignore
C:\Programs\nvm\v14.16.0\node_modules\ignite-cli\node_modules\gluegun\build\index.js:13
    throw up;
    ^
TypeError: Cannot read property 'replace' of undefined
    at C:\Programs\nvm\v14.16.0\node_modules\ignite-cli\build\commands\new.js:137:26
    at step (C:\Programs\nvm\v14.16.0\node_modules\ignite-cli\build\commands\new.js:44:23)
    at Object.next (C:\Programs\nvm\v14.16.0\node_modules\ignite-cli\build\commands\new.js:25:53)
    at fulfilled (C:\Programs\nvm\v14.16.0\node_modules\ignite-cli\build\commands\new.js:16:58)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)

andrewlorenz avatar Mar 29 '21 08:03 andrewlorenz

Hi all. Try react native doctor: npx @react-native-community/cli doctor

nirre7 avatar Mar 29 '21 17:03 nirre7

@andrewlorenz I had problems when I used Node v14.16.0 with this (I'm on the M1 Mac, some of the node versions have been a bit wonky for me), downgrading to v14.15.5 via NVM worked. Worth a shot!

jvgeee avatar Mar 30 '21 06:03 jvgeee

hey @jascination - thanks for the idea, but sadly no better:

PS C:\www> nvm install 14.15.5
Downloading node.js version 14.15.5 (64-bit)...
Complete
Creating C:\Programs\nvm\temp

Downloading npm version 6.14.11... Complete
Installing npm v6.14.11...

Installation complete. If you want to use this version, type

nvm use 14.15.5
PS C:\www> nvm use 14.15.5
Now using node v14.15.5 (64-bit)
PS C:\www> node -v
v14.15.5
PS C:\www> npm -v
6.14.11
PS C:\www> npx ignite-cli new ignited2 --debug
{
...
C:\Users\user\AppData\Roaming\npm-cache\_npx\12672\node_modules\ignite-cli\node_modules\gluegun\build\index.js:13
    throw up;
    ^

TypeError: Cannot read property 'replace' of undefined
    at C:\Users\user\AppData\Roaming\npm-cache\_npx\12672\node_modules\ignite-cli\build\commands\new.js:137:26
    at step (C:\Users\user\AppData\Roaming\npm-cache\_npx\12672\node_modules\ignite-cli\build\commands\new.js:44:23)
    at Object.next (C:\Users\user\AppData\Roaming\npm-cache\_npx\12672\node_modules\ignite-cli\build\commands\new.js:25:53)
    at fulfilled (C:\Users\user\AppData\Roaming\npm-cache\_npx\12672\node_modules\ignite-cli\build\commands\new.js:16:58)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)

andrewlorenz avatar Mar 30 '21 09:03 andrewlorenz

hey @nirre7 - I tried "doctor" but it said this:

Common
 ✓ Node.js
 ✓ yarn

Android
 ✖ JDK
   - Version found: 1.8.0_241
   - Version supported: >= 8
 ✓ Android Studio - Required for building and installing your app on Android
 ✓ Android SDK - Required for building and installing your app on Android
 ✓ ANDROID_HOME

Errors:   1
Warnings: 0

But given that my JDK IS version 8 (the 1.8.0_241 is misleading!) its not inspiring my confidence, though the other checks passed.

andrewlorenz avatar Mar 30 '21 09:03 andrewlorenz

Try: npx react-native init AwesomeProject If that fails please follow theses instructions => https://reactnative.dev/docs/environment-setup

nirre7 avatar Mar 30 '21 12:03 nirre7

hey @nirre7 that command worked fine, all the way to the end. The problem has to be with passing in a template - but only on windows, so it would appear. This command is the issue

npx react-native init ignited --template file://[disk-based path to ignite-cli] --verbose

I guess it could be react-native that's at fault, not ignite.

andrewlorenz avatar Mar 30 '21 14:03 andrewlorenz

Just for your interest, this command for me works

npx react-native init TestIgnite --template file:C:/Users/matte/AppData/Roaming/npm/node_modules/ignite-cli

but if i run npx ignite-cli new TestIgnite i get the same issue of @araymoises

adumat avatar Mar 30 '21 20:03 adumat

hey @adumat I've just tried something similar too and it also worked:

npx react-native init ignited --template file:\Programs\nvm\v14.16.0\node_modules\ignite-cli --verbose

whereas this failed:

npx react-native init ignited --template file://C:\Programs\nvm\v14.16.0\node_modules\ignite-cli --verbose

So there is something going awry with filenames on windows (but not linux/OSX) - no surprise there! The issue in ignite must relate to the same thing, as the .replace error occurs when it tries to read the template's package.json so it can overwrite the project name and save it back to disk. It would be nice to just run the ignite-cli command but as its broken, and unless/until it gets fixed, seems the next best thing is to manually run the steps it runs for us. I shall confirm those tomorrow and paste in here to help other fellow windows users.

andrewlorenz avatar Mar 30 '21 22:03 andrewlorenz

i did this and it worked for me.

npx react-native init MyApp --template react-native-template-typescript

then, subsequent ignite new app seems to work

ignite new MyTSProject

dennis3124 avatar Mar 30 '21 22:03 dennis3124

@dennis3124 I have try but won't work. Are you on windows?

adumat avatar Mar 31 '21 06:03 adumat

anyway, i have a stupid workaround. in file %USERPROFILE%\AppData\Roaming\npm\node_modules\ignite-cli\build\commands\new.js on line 90 replace

: "npx react-native init " + projectName + " --template file://" + ignitePath + (debug ? " --verbose" : "");

with

: "npx react-native init " + projectName + " --template file:" + ignitePath + (debug ? " --verbose" : "");

adumat avatar Mar 31 '21 06:03 adumat

this should shortcut ALL the issues on windows:

npx react-native init [your-project-name-here] --template https://github.com/infinitered/ignite --verbose

After its run, you just need to manually tidy up the "HelloWorld" references in the package.json (which is, as it turns out, where the ignite scripting to automagically do it goes wrong):

{
   "name": "hello-world",
    ....
       "ios.sim.debug": {
         "build": "xcodebuild -workspace ios/HelloWorld.xcworkspace -scheme HelloWorld -configuration Debug -sdk iphonesimulator -derivedDataPath ios/build -destination 'name=iPhone 11'",
         "type": "ios.simulator",
         "name": "iPhone 11"
       },
       "ios.sim.release": {
         "build": "xcodebuild -workspace ios/HelloWorld.xcworkspace -scheme HelloWorld -configuration Release -sdk iphonesimulator -derivedDataPath ios/build -destination 'name=iPhone 11'",

You just need to change these to match the project name you supplied to the init.

andrewlorenz avatar Apr 01 '21 17:04 andrewlorenz

Hi,

Returning to the topic, using terminal in admin mode, i did this to solve:

npx ignite-cli@3 new TG_APP --boilerplate ignite-bowser

I didn't try with a newer version of ignite-cli.

PS#1: It still shows me the error if i use "APP" as the project name.

PS#2: It works in the desktop folder (Windows).

araymoises avatar Apr 03 '21 16:04 araymoises

Hi all.

I ran windows 10 via virtual box and only installed the latest NodeJS LTS and VS Code, then I ran: npx ignite-cli new IgniteApp It created an IgniteApp based on the latest boilerplate in IgniteJS, with the correct names etc.

Could it be that you have and old version of ignitejs? Try to install another version of nodejs with for example nvm or similar to get a clean install i.e no global libs etc. Then try to create an app.

Good luck!

Screenshot 2021-04-05 at 16 23 06 Screenshot 2021-04-05 at 16 34 27

@araymoises That version of ignitejs and the boilerplate is old => https://shift.infinite.red/introducing-ignite-4-0-flame-1dfc891f9966

nirre7 avatar Apr 05 '21 14:04 nirre7