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

Error in create new app. #1639

Closed
araymoises opened this issue Mar 23, 2021 · 28 comments
Closed

Error in create new app. #1639

araymoises opened this issue Mar 23, 2021 · 28 comments

Comments

@araymoises
Copy link

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

@jvgeee
Copy link

jvgeee commented Mar 25, 2021

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?

@andrewlorenz
Copy link

andrewlorenz commented Mar 26, 2021

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
Copy link

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?

@hsavit1
Copy link

hsavit1 commented Mar 28, 2021

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
Copy link

hsavit1 commented Mar 28, 2021

FYI it worked when starting a new expo project

@andrewlorenz
Copy link

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)

@nirre7
Copy link
Collaborator

nirre7 commented Mar 29, 2021

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

@jvgeee
Copy link

jvgeee commented Mar 30, 2021

@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!

@andrewlorenz
Copy link

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
Copy link

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.

@nirre7
Copy link
Collaborator

nirre7 commented Mar 30, 2021

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

@andrewlorenz
Copy link

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.

@adumat
Copy link

adumat commented Mar 30, 2021

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

@andrewlorenz
Copy link

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.

@dennis3124
Copy link

dennis3124 commented Mar 30, 2021

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

@adumat
Copy link

adumat commented Mar 31, 2021

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

@adumat
Copy link

adumat commented Mar 31, 2021

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" : "");

@andrewlorenz
Copy link

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.

@araymoises
Copy link
Author

araymoises commented Apr 3, 2021

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).

@nirre7
Copy link
Collaborator

nirre7 commented Apr 5, 2021

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

@mversteeg3
Copy link

mversteeg3 commented Apr 6, 2021

I had this same issue and managed to fix it by setting my default node version to 12.X with the following commands:

  1. nvm install 12 (if not already installed)
  2. nvm alias default node

Hope this helps!

EDIT: Reading through some of the others in the thread I think it might be that the ignite cli installed in my node 10 was out of date, as I had used it for a previous app a while back. Installing node 12 and re-running with that instance likely got a fresh version. That's my current hypothesis, at least

@nirre7
Copy link
Collaborator

nirre7 commented Apr 7, 2021

To clarify, run :
npx ignite-cli doctor

IF you see any old version of ignite-cli installed globally (please refer to image below), remove it and use:
npx ignite-cli new AwesomeApp

image

@dsonet
Copy link

dsonet commented Apr 12, 2021

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" : "");

This doesn't work on windows 10 with node 14.16.0, the environment has no problem.

@dsonet
Copy link

dsonet commented Apr 12, 2021

To clarify, run :
npx ignite-cli doctor

IF you see any old version of ignite-cli installed globally (please refer to image below), remove it and use:
npx ignite-cli new AwesomeApp

image

No other ignite-cli installed, but it still fails.

@dsonet
Copy link

dsonet commented Apr 12, 2021

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.

This seems works for now.

@dsonet
Copy link

dsonet commented Apr 13, 2021

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" : "");

This doesn't work on windows 10 with node 14.16.0, the environment has no problem.

I tried replaced that part to:
"npx react-native init " + projectName + " --template " + ignitePath.replace('\\', '/') + (debug ? " --verbose" : "")
then it works.

I found out the root cause was happened here:

× Downloading template
error Error: Command failed: yarn add file://C:/Users/jzhang/AppData/Roaming/nvm/v14.16.0/node_modules/ignite-cli
error Package "file://C:/Users/jzhang/AppData/Roaming/nvm/v14.16.0/node_modules/ignite-cli" refers to a non-existing file '"//C:/Users/jzhang/AppData/Roaming/nvm/v14.16.0/node_modules/ignite-cli"'.

I think this should be fixed in yarn. Not sure how to fix this yet.

aliassar added a commit to aliassar/ignite that referenced this issue Apr 24, 2021
infinitered-circleci pushed a commit that referenced this issue Apr 29, 2021
## [6.9.2](v6.9.1...v6.9.2) (2021-04-29)

### Bug Fixes

* **windows:** Fix issue [#1639](#1639) -- remove "file://" from template address ([#1663](#1663) by [@aliassar](https://github.com/aliassar)) ([fcfcf2e](fcfcf2e))
@jamonholmgren
Copy link
Member

@bawantha
Copy link

These JS frameworks are so sh** even can't do a fresh installation , Hate JS forever

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