Npm install failed

Hi, I just started to learn TensorFlow.

I got the message as below after inputting

npm install

How can I fix this?


npm ERR! code 1

npm ERR! path /Users/svj5706/Documents/Machine Learning/MLKits-master/knn-tf/node_modules/@tensorflow/tfjs-node

npm ERR! command failed

npm ERR! command sh -c node scripts/install.js

npm ERR! * Downloading libtensorflow

npm ERR!

npm ERR! * Building TensorFlow Node.js bindings

npm ERR! /Users/svj5706/Documents/Machine Learning/MLKits-master/knn-tf/node_modules/@tensorflow/tfjs-node/scripts/install.js:154

npm ERR! throw new Error('node-gyp rebuild failed with: ' + err);

npm ERR! ^

npm ERR!

npm ERR! Error: node-gyp rebuild failed with: Error: Command failed: node-gyp rebuild

npm ERR! gyp info it worked if it ends with ok

npm ERR! gyp info using node-gyp@7.1.2

npm ERR! gyp info using node@16.13.0 | darwin | x64

npm ERR! gyp info find Python using Python version 2.7.16 found at "/usr/bin/python"

npm ERR! (node:88710) [DEP0150] DeprecationWarning: Setting process.config is deprecated. In the future the property will be read-only.

npm ERR! (Use `node --trace-deprecation ...` to show where the warning was created)

npm ERR! gyp info spawn /usr/bin/python

npm ERR! gyp info spawn args [

npm ERR! gyp info spawn args '/Users/svj5706/node_modules/node-gyp/gyp/gyp_main.py',

npm ERR! gyp info spawn args 'binding.gyp',

npm ERR! gyp info spawn args '-f',

npm ERR! gyp info spawn args 'make',

npm ERR! gyp info spawn args '-I',

npm ERR! gyp info spawn args '/Users/svj5706/Documents/Machine Learning/MLKits-master/knn-tf/node_modules/@tensorflow/tfjs-node/build/config.gypi',

npm ERR! gyp info spawn args '-I',

npm ERR! gyp info spawn args '/Users/svj5706/node_modules/node-gyp/addon.gypi',

npm ERR! gyp info spawn args '-I',

npm ERR! gyp info spawn args '/Users/svj5706/Library/Caches/node-gyp/16.13.0/include/node/common.gypi',

npm ERR! gyp info spawn args '-Dlibrary=shared_library',

npm ERR! gyp info spawn args '-Dvisibility=default',

npm ERR! gyp info spawn args '-Dnode_root_dir=/Users/svj5706/Library/Caches/node-gyp/16.13.0',

npm ERR! gyp info spawn args '-Dnode_gyp_dir=/Users/svj5706/node_modules/node-gyp',

npm ERR! gyp info spawn args '-Dnode_lib_file=/Users/svj5706/Library/Caches/node-gyp/16.13.0/<(target_arch)/node.lib',

npm ERR! gyp info spawn args '-Dmodule_root_dir=/Users/svj5706/Documents/Machine Learning/MLKits-master/knn-tf/node_modules/@tensorflow/tfjs-node',

npm ERR! gyp info spawn args '-Dnode_engine=v8',

npm ERR! gyp info spawn args '--depth=.',

npm ERR! gyp info spawn args '--no-parallel',

npm ERR! gyp info spawn args '--generator-output',

npm ERR! gyp info spawn args 'build',

npm ERR! gyp info spawn args '-Goutput_dir=.'

npm ERR! gyp info spawn args ]

npm ERR! Traceback (most recent call last):

npm ERR! File "/Users/svj5706/node_modules/node-gyp/gyp/gyp_main.py", line 51, in <module>

npm ERR! sys.exit(gyp.script_main())

npm ERR! File "/Users/svj5706/node_modules/node-gyp/gyp/pylib/gyp/__init__.py", line 670, in script_main

npm ERR! return main(sys.argv[1:])

npm ERR! File "/Users/svj5706/node_modules/node-gyp/gyp/pylib/gyp/__init__.py", line 662, in main

npm ERR! return gyp_main(args)

npm ERR! File "/Users/svj5706/node_modules/node-gyp/gyp/pylib/gyp/__init__.py", line 647, in gyp_main

npm ERR! generator.GenerateOutput(flat_list, targets, data, params)

npm ERR! File "/Users/svj5706/node_modules/node-gyp/gyp/pylib/gyp/generator/make.py", line 2457, in GenerateOutput

npm ERR! part_of_all=qualified_target in needed_targets,

npm ERR! File "/Users/svj5706/node_modules/node-gyp/gyp/pylib/gyp/generator/make.py", line 804, in Write

npm ERR! part_of_all,

npm ERR! File "/Users/svj5706/node_modules/node-gyp/gyp/pylib/gyp/generator/make.py", line 1005, in WriteActions

npm ERR! "Spaces in action input filenames not supported (%s)" % input

npm ERR! AssertionError: Spaces in action input filenames not supported (/Users/svj5706/Documents/Machine Learning/MLKits-master/knn-tf/node_modules/@tensorflow/tfjs-node/scripts/deps-stage.js)

npm ERR! gyp ERR! configure error

npm ERR! gyp ERR! stack Error: `gyp` failed with exit code: 1

npm ERR! gyp ERR! stack at ChildProcess.onCpExit (/Users/svj5706/node_modules/node-gyp/lib/configure.js:351:16)

npm ERR! gyp ERR! stack at ChildProcess.emit (node:events:390:28)

npm ERR! gyp ERR! stack at Process.ChildProcess._handle.onexit (node:internal/child_process:290:12)

npm ERR! gyp ERR! System Darwin 18.7.0

npm ERR! gyp ERR! command "/usr/local/bin/node" "/Users/svj5706/node_modules/.bin/node-gyp" "rebuild"

npm ERR! gyp ERR! cwd /Users/svj5706/Documents/Machine Learning/MLKits-master/knn-tf/node_modules/@tensorflow/tfjs-node

npm ERR! gyp ERR! node -v v16.13.0

npm ERR! gyp ERR! node-gyp -v v7.1.2

npm ERR! gyp ERR! not ok

npm ERR!

npm ERR! at /Users/svj5706/Documents/Machine Learning/MLKits-master/knn-tf/node_modules/@tensorflow/tfjs-node/scripts/install.js:154:13

npm ERR! at ChildProcess.exithandler (node:child_process:404:5)

npm ERR! at ChildProcess.emit (node:events:390:28)

npm ERR! at maybeClose (node:internal/child_process:1064:16)

npm ERR! at Process.ChildProcess._handle.onexit (node:internal/child_process:301:5)



npm ERR! A complete log of this run can be found in:

npm ERR! /Users/svj5706/.npm/_logs/2021-12-02T07_44_05_986Z-debug.log

Can you provide more details about the platform etc you are running on? What are you running npm install on exactly? From the first error it seems no spaces are allowed in path names and your path has a space in it.

Hi, Jason

My OS is Mac Mojave.

I typed npm install on knn-tf directory which I created for machine learning project.

The directory has the files as below

  • index.js
  • load-csv.js
  • data.csv
  • package-lock.json
  • package.json

Node version is v16.13.0

Thanks for helping me :slight_smile:

Can you try correcting your file path first?