-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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: astro add
could not update config file safely
#3071
Comments
@lucywho can you share the The message mentions |
astro add
could not update config file safely
astro.config.mjs
package.json
|
Looks like it works fine in Stackblitz. |
I got the same error and my astro.config.mjs and package.json are the same as Lucywho's with the exception of my package.json says beta.9 instead of 8 |
Seeing the same myself on beta 14 now. Feels like maybe something being cached as I had this a while back and it resolved itself at some point, but happening again now. And works fine on my laptop. |
This looks to be related to an outdated version on Node. Works fine on my laptop with Node v16.14 and was seeing the [t.identifier] error on my PC that had Node v14.16.1. Downgraded my laptop to Node 14.16.1 and reproduced the error. The change I made to fix this was (which is no longer needed as we just need to update to Node v16.14) was to import from @babel/types using explicit imports. @babel/types is a commonJS package and as such the latest import that we use (import * as t from @babel/types) does not work on older versions it seems. @lucywho @Web-Dev-Taz could you check which version of Node you have to confirm maybe? |
I've got Node v 16.14.2, so its not that unfortunately |
Looks like multiple things can affect the import from Babel with yours still showing the issue I guess. I can't reproduce since my node upgrade I'm afraid though sorry. Before my node upgrade I managed to get it working by explicitly importing from babel types - one option there I guess if you need to run.. |
I can't reproduce, sorry! If anyone can track down a solid reproduction, we can take a look, but it's hard to debug without knowing. Otherwise, if you can reproduce and feel comfortable putting some console logs inside of your |
@FredKSchott I'm having this same issue. I simply ran When I then run Here's what Within "use strict";
import generator from "@babel/generator";
import parser from "@babel/parser";
import traverse from "@babel/traverse";
import {default as t} from "@babel/types"; // Updated this line to set default as t
const visit = traverse.default;
async function generate(ast) {
const astToText = generator.default;
const { code } = astToText(ast);
return code;
}
const parse = (code) => parser.parse(code, { sourceType: "unambiguous", plugins: ["typescript"] });
export {
generate,
parse,
t,
visit
} NPM Version: 6.14.8 Used nvm to change node versions to the following, at it worked fine: NPM Version: 8.13.2 |
Thanks for digging into this, everyone! We have the infrastructure in place to give you helpful warnings when you're using an incompatible version of Node, but our I opened #3871 to update those fields. |
Co-authored-by: Nate Moore <[email protected]>
Updating node to 16 solved it for me :) |
It seems an attempt to install astro within a turbo (mono)repo fails with this error. Versions
Script to reproduce#!/usr/bin/env sh
CWD=`pwd`
TURBO_PROJECT=turbo-sample
UI_APP=astro-app
# setup turbo repo
npx create-turbo@latest $TURBO_PROJECT
cd $CWD/$TURBO_PROJECT
rm -rf apps/$UI_APP
mkdir -p apps/$UI_APP
cd $CWD/$TURBO_PROJECT/apps/$UI_APP
# setup astro project
npm create astro@latest
# select '.' for a directory
# add astro plugins
npm run astro add svelte
npm run astro add tailwind
cd $CWD ExpectationThese commands succeed.
ActualIt seems that npm installs dependencies in the monorepo root, so there is a missing package-lock.json in the astro repo. If I CTRL-C out of the install section, it'll update the astro.config.mjs.
Complete run log
|
@sramam I ran into this as well, but running |
Co-authored-by: Nate Moore <[email protected]>
it appears I'm facing a similar issue with the turborepo setup with regards to pnpm-lock.yaml file in my case if I create a standalone project it works without any issue but if I install it in a mono repo env it fails to add astro integrations, by any chance did u find a fix for it ? |
I also run into this bug with workspaces an Astro. To reproduce:
This results in:
@tony-sull I'm not able to reopen this issue here, but I dont want to create a new issue to keep it relevant to the discussion here. |
Can confirm, it seems to be related with workspaces or something. Ran into this in a turbo monorepo with pnpm workspaces |
Still getting this error in sst monorepo @nsquaredotone did you find any solution to this? |
Same issue in an Astro Turborepo. Node 18, Astro 3.3.5. I don't see a resolution in this thread, but there must be if its closed. For those of us coming in down the line please present path to accurate implementation. |
Got the same issue using Bun 1.1.22. I am using Fedora Linux. |
Got the same issue using Bun 1.1.24. I am using Ubuntu Linux. |
What version of
astro
are you using?1.0.0-beta.7
Are you using an SSR adapter? If so, which one?
none
What package manager are you using?
npm
What operating system are you using?
Linux
Describe the Bug
Set up a new astro project using Minimal template
Attempted to install tailwindcss using
npx astro add tailwind
Got error message
error Astro could not update your astro.config.js file safely. Reason: t.identifier is not a function
Link to Minimal Reproducible Example
I have no idea how to do this
Participation
The text was updated successfully, but these errors were encountered: