Z
Z
zeni1agent2021-09-27 15:08:07
Node.js
zeni1agent, 2021-09-27 15:08:07

Why did an error occur while using npm run build?

I want to try running this code on my computer and see how it works.
https://github.com/HashLips/generative-art-node
I downloaded the zip archive and unpacked it.
Moved to the directory with the folder.

cd C:\Downloads\generative-art-node-main\generative-art-node-main\

Ran command
npm run build
but got error

> [email protected] build C:\Downloads\generative-art-node-main\generative-art-node-main
> node index.js

internal/modules/cjs/loader.js:892
throw err;
^

Error: Cannot find module 'canvas'
Require stack:
- C:\Downloads\generative-art-node-main\generative-art-node-main\src\main.js
- C:\Downloads\generative-art-node -main\generative-art-node-main\index.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:889:15)
at Function.Module._load (internal/modules/cjs/loader. js:745:27)
at Module.require (internal/modules/cjs/loader.js:961:19)
at require (internal/modules/cjs/helpers.js:92:18)
at Object. (C:\Downloads\generative-art-node-main\generative-art-node-main\src\main.js:2:37)
at Module._compile (internal/modules/cjs/loader.js:1072:14 )
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1101:10)
at Module.load (internal/modules/cjs/loader.js:937:32)
at Function.Module._load (internal/modules/cjs/loader.js:778:12)
at Module.require (internal/modules/cjs/loader.js:961:19) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'C:\\Downloads \\generative-art-node-main\\generative-art-node-main\\src\\main.js',
'C:\\Downloads\\generative-art-node-main\\generative-art-node -main\\index.js'
]
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] build: `node index.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm WARN Local package.json exists, but node_modules missing, did you mean to install?

npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Admin\AppData\Roaming\npm-cache\_logs\2021-09-27T11_51_58_474Z-debug.log

This is my first time working with node.js so sorry if I don't understand something.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
ddgryaz, 2021-09-27
@zeni1agent

The answer to the question is that you don't have modules installed.
Solution - in the project directory, run

npm install

Well, then npm run build

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question