question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

NPM Missing Generate Script

See original GitHub issue

Version

v2.13.1

Reproduction link

https://github.com/ngblaylock/nuxt-sandbox/tree/npm-missing-generate-script

Steps to reproduce

When I do a standard npx create-nuxt-app project, my project is set up just fine. I use NPM instead of Yarn. Then, as per the README.md file, I run npm run generate where I get an error.

I can get it to work if I manually put in “generate”: “nuxt generate” in the package.json file, it works, but it is not there by default.

What is expected ?

I expect Nuxt to generate static files into a dist directory.

What is actually happening?

When I go to generate the static files, I get npm ERR! missing script: generate.

Additional comments?

I was going to submit this through codesandbox.com, but I believe since they use Yarn, it works out of the box.

<div align="right">This bug report is available on Nuxt community (#c10849)</div>

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
ngblaylockcommented, Jun 26, 2020

That makes sense. Then I would still suggest a change on the default README.md to say something along the lines of:

# generate static project
# first ensure target is set to 'static' in the nuxt.config.js file
$ npm run build
$ npm run export

When I follow the instructions to generate a static project in the README.md file, it threw an error since npm run generate didn’t exist. I think new developers could get easily confused by that.

I also noticed that I needed to run nuxt build --target static if I didn’t configure nuxt.config.js.

Something to consider that I think works pretty good is to add

"static": "nuxt build --target static && nuxt export"

to my package.json scripts section. Then run npm run static. Is that a logical script? That considerations is probably better for future readers than for official Nuxt documentation.

1reaction
pi0commented, Jun 26, 2020

Hi @ngblaylock. Actually this change is to encourage using new nuxt export (npm run export) command for static target. You can still add "generate": "nuxt generate" to package.json scripts section for legacy generate.

Docs should be already updated to mention using export (instead of generate).

Read more comments on GitHub >

github_iconTop Results From Across the Web

npm ERR! Missing script: "build" [Solved] | bobbyhadz
To solve the npm ERR! Missing script: "build" error, make sure to add a build command to the scripts object in your package.json...
Read more >
Using "npm run build" fails with "npm ERR! missing script: build"
First check you have .babelrc file in your root folder. if you already have. Add this in your package.json file "scripts": { "dev":...
Read more >
Missing script generate · Issue #480 - GitHub
I have got to the point where my traits are ready and named. when I run: npm run generate or npm generate I...
Read more >
What does it mean when you get the NPM error missing script
It means in your “package.json” (in the folder in which you run “npm run build”), there's NO “build” script. A quick check: run...
Read more >
[Solved] npm err! missing script: start - ItsJavaScript
How to fix npm err! missing script: start · Solution 1 – Add the Start Scripts in package.json · Solution 2 – Ensure...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found