withastro / astro

The web framework for content-driven websites. ⭐️ Star to support our work!
https://astro.build
Other
46.41k stars 2.46k forks source link

🐛 BUG: blog start template doesn't run #1647

Closed altano closed 3 years ago

altano commented 3 years ago

What package manager are you using?

npm

What operating system are you using?

Linux

Describe the Bug

When creating a blog starter using npm init astro I get a site that won't run. npm run dev gives me the error:

file:///home/alan/src/alan.norbauer.com-astro/node_modules/astro/dist/build/bundle/js.js:2
import {rollup} from "rollup";
        ^^^^^^
SyntaxError: Named export 'rollup' not found. The requested module 'rollup' is a CommonJS module, which may not support all module.exports as named exports.
CommonJS modules can always be imported via the default export, for example using:

Steps to Reproduce

(using node v17.0.1)

  1. npm init astro using template blog
  2. npm i
  3. npm run dev
alan@code ~/s/alan.norbauer.com-astro> npm i && npm run dev
npm WARN deprecated har-validator@5.1.5: this library is no longer supported
npm WARN deprecated uuid@3.4.0: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated vscode-emmet-helper@2.1.2: This package has been renamed to @vscode/emmet-helper, please update to the new name

added 908 packages, and audited 909 packages in 9s

194 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities

> @example/blog@0.0.1 dev
> astro dev

file:///home/alan/src/alan.norbauer.com-astro/node_modules/astro/dist/build/bundle/js.js:2
import {rollup} from "rollup";
        ^^^^^^
SyntaxError: Named export 'rollup' not found. The requested module 'rollup' is a CommonJS module, which may not support all module.exports as named exports.
CommonJS modules can always be imported via the default export, for example using:

import pkg from 'rollup';
const {rollup} = pkg;

    at ModuleJob._instantiate (node:internal/modules/esm/module_job:124:21)
    at async ModuleJob.run (node:internal/modules/esm/module_job:181:5)
    at async Promise.all (index 0)
    at async ESMLoader.import (node:internal/modules/esm/loader:281:24)

Link to Minimal Reproducible Example (Optional)

No response

raph5 commented 3 years ago

i have the same problem

zenshindm commented 3 years ago

Same issue

What operating system are you using? Window here

import {rollup} from "rollup"; ^^^^^^ SyntaxError: Named export 'rollup' not found. The requested module 'rollup' is a CommonJS module, which may not support all module.exports as named exports. CommonJS modules can always be imported via the default export, for example using:

import pkg from 'rollup'; const {rollup} = pkg;

matthewp commented 3 years ago

This could be the reason: https://github.com/rollup/rollup/issues/4253

oliverturner commented 3 years ago

@matthewp rolling back to rollup@2.58.0 addressed the missing export issue, but led to the following error:

<path-to-project>/node_modules/.pnpm/@astrojs+language-server@0.7.19/node_modules/@astrojs/language-server/dist/check.js:46
            text: this.docManager.get(uri)?.getText() || '',

SyntaxError: Unexpected token '.'
matthewp commented 3 years ago

What about 2.58.3?

https://github.com/rollup/rollup/commit/2fa12c1ebed21906a25837cb3cc4678296ff2f88

oliverturner commented 3 years ago

rollup@2.58.3 works great

~but again @astrojs/language-server is the problem: the optional chaining and nullish coalescing operators are triggering syntax errors~

Turns out I hadn't understood Volta manages dependencies: despite running node@16, the fact that I had installed pnpm under node@12 meant that this was the version of node used when runnning pnpx astro check

matthewp commented 3 years ago

So alls good now?

oliverturner commented 3 years ago

Sorry... yes!

Can confirm that using rollup@2.58.3 addresses the issue 👍

altano commented 3 years ago

I appreciate the workaround but shouldn’t astro itself update the dependency as well? https://github.com/snowpackjs/astro/blob/059aff923b27b7758fc4daffdc1b2506b6fb0a8c/packages/astro/package.json#L92

stephanbogner commented 2 years ago

I had the same issue for find-up (using Astro version 1.3.0 on MacOS)

Update: OK, it happened again at the step generating static routes (even after deleting node_modules and running npm install):

Show console output ``` [MDX] Now inheriting remark and rehype plugins from "markdown" config. If you applied a plugin to both your Markdown and MDX configs, we suggest removing the duplicate MDX entry. See "extendPlugins" option to configure this behavior. 09:57:50 AM [build] output target: static 09:57:50 AM [build] Collecting build info... 09:57:50 AM [build] Completed in 0.86s. 09:57:53 AM [build] Building static entrypoints... 09:58:26 AM [build] Completed in 33.47s. building client Completed in 10.38s. generating static routes error Named export 'findUp' not found. The requested module 'find-up' is a CommonJS module, which may not support all module.exports as named exports. CommonJS modules can always be imported via the default export, for example using: import pkg from 'find-up'; const { findUp } = pkg; file:///Users/stephan/Documents/Projekte-kommerziell/project-xyz/repository/dist/entry.mjs?time=1664351917114:21 import { findUp } from 'find-up'; ^^^^^^ SyntaxError: Named export 'findUp' not found. The requested module 'find-up' is a CommonJS module, which may not support all module.exports as named exports. CommonJS modules can always be imported via the default export, for example using: import pkg from 'find-up'; const { findUp } = pkg; at ModuleJob._instantiate (internal/modules/esm/module_job.js:124:21) at async ModuleJob.run (internal/modules/esm/module_job.js:179:5) at async Loader.import (internal/modules/esm/loader.js:178:24) at async generatePages (file:///Users/stephan/Documents/Projekte-kommerziell/project-xyz/repository/node_modules/astro/dist/core/build/generate.js:71:20) at async staticBuild (file:///Users/stephan/Documents/Projekte-kommerziell/project-xyz/repository/node_modules/astro/dist/core/build/static-build.js:68:5) at async AstroBuilder.build (file:///Users/stephan/Documents/Projekte-kommerziell/project-xyz/repository/node_modules/astro/dist/core/build/index.js:86:5) at async AstroBuilder.run (file:///Users/stephan/Documents/Projekte-kommerziell/project-xyz/repository/node_modules/astro/dist/core/build/index.js:127:7) at async build (file:///Users/stephan/Documents/Projekte-kommerziell/project-xyz/repository/node_modules/astro/dist/core/build/index.js:22:3) at async runCommand (file:///Users/stephan/Documents/Projekte-kommerziell/project-xyz/repository/node_modules/astro/dist/cli/index.js:190:14) at async cli (file:///Users/stephan/Documents/Projekte-kommerziell/project-xyz/repository/node_modules/astro/dist/cli/index.js:207:5) ```
narsiliko commented 1 year ago

I have the same problem with the Vue3Marquee Using Astro 1.6.0 Here is the console output:

$ npm run build

> @example/minimal@0.0.1 build
> astro build

16:38:00 [build] output target: static
16:38:00 [build] Collecting build info...
16:38:00 [build] Completed in 12ms.
16:38:00 [build] Building static entrypoints...
16:38:02 [build] Completed in 1.28s.

 building client 
Completed in 683ms.

 generating static routes 
 error   Named export 'Vue3Marquee' not found. The requested module 'vue3-marquee' is a CommonJS module, which may not support all module.exports as named exports.
  CommonJS modules can always be imported via the default export, for example using:

  import pkg from 'vue3-marquee';
  const { Vue3Marquee } = pkg;

  File:
    file
  Stacktrace:
file:///home/***/dist/entry.mjs?time=1668584282824:4
/* empty css                                 */import { Vue3Marquee } from 'vue3-marquee';
                                                        ^^^^^^^^^^^
SyntaxError: Named export 'Vue3Marquee' not found. The requested module 'vue3-marquee' is a CommonJS module, which may not support all module.exports as named exports.
CommonJS modules can always be imported via the default export, for example using:

import pkg from 'vue3-marquee';
const { Vue3Marquee } = pkg;

    at ModuleJob._instantiate (node:internal/modules/esm/module_job:123:21)
    at async ModuleJob.run (node:internal/modules/esm/module_job:189:5)
    at async Promise.all (index 0)
    at async ESMLoader.import (node:internal/modules/esm/loader:526:24)
    at async generatePages (file:///home/***/node_modules/astro/dist/core/build/generate.js:53:20)
    at async staticBuild (file:///home/***/node_modules/astro/dist/core/build/static-build.js:70:5)
    at async AstroBuilder.build (file:///home/***/node_modules/astro/dist/core/build/index.js:87:5)
    at async AstroBuilder.run (file:///home/***/node_modules/astro/dist/core/build/index.js:128:7)
    at async build (file:///home/***/node_modules/astro/dist/core/build/index.js:22:3)
    at async runCommand (file:///home/***/node_modules/astro/dist/cli/index.js:191:14)