OfficeDev/generator-office

"Npm start" failed with error

xiruatms opened this issue · 9 comments

In a workshop, this page was used. But all failed when trying to start the dev server with "npm start", please see the attached screenshot for the details:
image

The generated files are:
image

Prerequisites

Please answer the following questions before submitting an issue.
YOU MAY DELETE THE PREREQUISITES SECTION.

  • I am running the latest version of Node and the tools
  • I checked the documentation and found no answer
  • I checked to make sure that this issue has not already been filed

Expected behavior

Please describe the behavior you were expecting
dev server succeeded.

Current behavior

dev server failed with errors.

Please provide information about the failure. What is the current behavior? If it is not a bug, please add it to UserVoice, so that it gets added to our feature roadmap.

Steps to Reproduce

Please provide detailed steps for reproducing the issue.

https://learn.microsoft.com/en-us/office/dev/add-ins/develop/yeoman-generator-overview

Context

Please provide any relevant information about your setup. This is important in case the issue is not reproducible except for under certain conditions.

  • Operating System:
  • Node version:
  • Office version:
  • Tool version:

Failure Logs

Please include any relevant log snippets, screenshots or code samples here.
image

Receiving same error on Mac for all package.json script commands.

Same here:

Operating System: macOS Ventura, (m1)
Node version: v18.8.0
Office version: Microsoft Word for Mac, Version 16.72
Tool version: 1.9.5 - 1.8.0

Same here.
Can you please let me know the way to fix this issue?
image

It looks like some of the file are missing from the project that was generated. Can someone provide the full output of the 'yo office' command that they ran?

Using node v18.16.0 (npm v9.5.1)
➜ excel_graphql yo office

 _-----_     ╭──────────────────────────╮
|       |    │   Welcome to the Office  │
|--(o)--|    │   Add-in generator, by   │

---------´ │ @OfficeDev! Let's create │ ( _´U_ ) │ a project together! │
/A\ /╰──────────────────────────╯
| ~ |
'..'_
´ |° ´ Y

? Choose a project type: Office Add-in Task Pane project
? Choose a script type: JavaScript
? What do you want to name your add-in? My Office Add-in
? Which Office client application would you like to support? Excel


  Creating My Office Add-in add-in for Excel using JavaScript and Taskpane at /Users/user/Documents/dev/testing/excel_graphql/My Office Add-in

I'm all done. Running npm install for you to install the required dependencies. If this fails, try running the command yourself.

No change to package.json was detected. No package manager install will be executed.
npm WARN config cache-min This option has been deprecated in favor of --prefer-offline.
npm WARN deprecated @types/jwt-decode@3.1.0: This is a stub types definition. jwt-decode provides its own type definitions, so you do not need this installed.
npm WARN deprecated readdir-scoped-modules@1.1.0: This functionality has been moved to @npmcli/fs
npm WARN deprecated @npmcli/move-file@1.1.2: This functionality has been moved to @npmcli/fs
npm WARN deprecated @npmcli/move-file@2.0.1: This functionality has been moved to @npmcli/fs

added 1266 packages, and audited 1267 packages in 23s

161 packages are looking for funding
run npm fund for details

8 moderate severity vulnerabilities

To address issues that do not require attention, run:
npm audit fix

To address all issues (including breaking changes), run:
npm audit fix --force

Run npm audit for details.

  Congratulations! Your add-in has been created! Your next steps:

  1. Go the directory where your project was created:

     cd "/Users/user/Documents/dev/testing/excel_graphql/My Office Add-in"

  2. Start the local web server and sideload the add-in:

     npm start

  3. Open the project in VS Code:

     code .

     For more information, visit http://code.visualstudio.com.

  Please visit https://learn.microsoft.com/office/dev/add-ins for more information about Office Add-ins.

➜ excel_graphql cd My\ Office\ Add-in
➜ My Office Add-in ls
assets babel.config.json manifest.xml node_modules package-lock.json package.json src
➜ My Office Add-in npm run build:dev

office-addin-taskpane-js@0.0.1 build:dev
webpack --mode development

asset main.js 667 bytes [emitted] (name: main)

ERROR in main
Module not found: Error: Can't resolve './src' in '/Users/user/Documents/dev/testing/excel_graphql/My Office Add-in'
resolve './src' in '/Users/user/Documents/dev/testing/excel_graphql/My Office Add-in'
using description file: /Users/user/Documents/dev/testing/excel_graphql/My Office Add-in/package.json (relative path: .)
Field 'browser' doesn't contain a valid alias configuration
using description file: /Users/user/Documents/dev/testing/excel_graphql/My Office Add-in/package.json (relative path: ./src)
no extension
Field 'browser' doesn't contain a valid alias configuration
/Users/user/Documents/dev/testing/excel_graphql/My Office Add-in/src is not a file
.js
Field 'browser' doesn't contain a valid alias configuration
/Users/user/Documents/dev/testing/excel_graphql/My Office Add-in/src.js doesn't exist
.json
Field 'browser' doesn't contain a valid alias configuration
/Users/user/Documents/dev/testing/excel_graphql/My Office Add-in/src.json doesn't exist
.wasm
Field 'browser' doesn't contain a valid alias configuration
/Users/user/Documents/dev/testing/excel_graphql/My Office Add-in/src.wasm doesn't exist
as directory
existing directory /Users/user/Documents/dev/testing/excel_graphql/My Office Add-in/src
using description file: /Users/user/Documents/dev/testing/excel_graphql/My Office Add-in/package.json (relative path: ./src)
using path: /Users/user/Documents/dev/testing/excel_graphql/My Office Add-in/src/index
using description file: /Users/user/Documents/dev/testing/excel_graphql/My Office Add-in/package.json (relative path: ./src/index)
no extension
Field 'browser' doesn't contain a valid alias configuration
/Users/user/Documents/dev/testing/excel_graphql/My Office Add-in/src/index doesn't exist
.js
Field 'browser' doesn't contain a valid alias configuration
/Users/user/Documents/dev/testing/excel_graphql/My Office Add-in/src/index.js doesn't exist
.json
Field 'browser' doesn't contain a valid alias configuration
/Users/user/Documents/dev/testing/excel_graphql/My Office Add-in/src/index.json doesn't exist
.wasm
Field 'browser' doesn't contain a valid alias configuration
/Users/user/Documents/dev/testing/excel_graphql/My Office Add-in/src/index.wasm doesn't exist

webpack 5.82.1 compiled with 1 error in 60 ms

It looks like a new version of 'unzipper' got published a couple days ago with a flaw somewhere in it. This plugin depends on that package when extracting a downloaded the github zip file and the extraction is finishing without getting all the files and without reporting an error.

Will need to target the specific version of the package until a fix is made. New version of generator-office forth coming.

In the meantime . . . if you can force the use of unzipper 0.10.11 locally then 'yo office' will work again. Otherwise, you can clone or download and extract the template repo (office-addin-taskpane*) and run 'npm run convert-to-single-host' command with the argument of which host you would like the project to work with.

Thanks for the quick turnaround!

Was having the same error when trying to use Yo for first time today to create an Outlook add-in. Per @millerds suggestion, I targeted an older version of unzipper (0.10.11) and everything then worked. I use nvm to manage node versions, so had to find the appropriate place to make the version change as follows:

  1. Find where node is installed: which node = /Users/myusername/.nvm/versions/node/v18.16.0/bin/node

  2. Within /Users/myusername/.nvm/versions/node/v18.16.0/lib/node_modules/generator-office:

  3. delete existing node_modules directory

  4. change line 48 within package.json from "unzipper": "^0.10.11", to "unzipper": "0.10.11",

  5. run npm install

  6. From my project root, re-run yo to generate my template.

Update published. Please use latest version.