javascriptvisual-studio-codebrain.js

Error installing brain.js in Visual Studio Code


newbie here. I had recently switched over to Visual Studio Code to work with Brain.js but when I go to install it into the terminal (With NPM), I get an Error. I have tried multiple other solutions but none work. Any help would be appreciated. Thanx in advance =>

Since I am new also at Linux, I had tried a few variations of install commands(like sudo) and tried to complete the Brain.js installation on Default Linux terminal but to no avail :( . Also a weird thing is that I was able to download BrainJS(Older lib.) but not Brain.js

Even though i don't think there is any problem with the code, Here is it anyways.

const brain = require("brainjs");
let net = new brain.NeuralNetwork({ hiddenLayers: [3] });   // 
Setting up neural network

const restaurants = {                     // Dataset
  "KFC":"Monday",
  "Item no.1":"Tuesday",
  "Vaango":"Wednesday",
  "Taco Bell":"Thursday",
  "carls Jr.":"Friday",
  "":"Saturday",
  "Burger King":"Sunday"
}

const TrainingData = [];

for (let restaurantName in restaurants) {
    const dayOfWeek = restaurants[restaurantName];
    TrainingData.push({
      input: { [dayOfWeek]: 1 },
      output: { [restaurantName]: 1 }
});
}


const stats = net.train(TrainingData);

THIS IS THE ERROR MSG I AM GETTING:

    npm ERR! Linux 5.0.0-23-generic
    npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "install" "brain.js"
    npm ERR! node v8.10.0
    npm ERR! npm  v3.5.2
    npm ERR! code EMISSINGARG

    npm ERR! typeerror Error: Missing required argument #1
    npm ERR! typeerror     at andLogAndFinish (/usr/share/npm/lib/fetch- 
    package-metadata.js:31:3)
    npm ERR! typeerror     at fetchPackageMetadata 
    (/usr/share/npm/lib/fetch-package-metadata.js:51:22)
    npm ERR! typeerror     at resolveWithNewModule 
    (/usr/share/npm/lib/install/deps.js:456:12)
    npm ERR! typeerror     at /usr/share/npm/lib/install/deps.js:190:5
    npm ERR! typeerror     at 
    /usr/share/npm/node_modules/slide/lib/async-map.js:52:35
    npm ERR! typeerror     at Array.forEach (<anonymous>)
    npm ERR! typeerror     at 
    /usr/share/npm/node_modules/slide/lib/async-map.js:52:11
    npm ERR! typeerror     at Array.forEach (<anonymous>)
    npm ERR! typeerror     at asyncMap 

(/usr/share/npm/node_modules/slide/lib/async-map.js:51:8)
npm ERR! typeerror     at exports.loadRequestedDeps (/usr/share/npm/lib/install/deps.js:188:3)
npm ERR! typeerror This is an error with npm itself. Please report this error at:
npm ERR! typeerror     <http://github.com/npm/npm/issues>

npm ERR! Please include the following file with any support request:
npm ERR!     /home/neel/Documents/VS-Code_Projects/npm-debug.log

AND THE DEBUG LOG:--

0 info it worked if it ends with ok
1 verbose cli [ '/usr/bin/node', '/usr/bin/npm', 'install', 'brain.js' ]
2 info using npm@3.5.2
3 info using node@v8.10.0
4 verbose config Skipping project config: /home/neel/.npmrc. (matches userconfig)
5 silly loadCurrentTree Starting
6 silly install loadCurrentTree
7 silly install readLocalPackageData
8 silly fetchPackageMetaData brain.js
9 silly fetchNamedPackageData brain.js
10 silly mapToRegistry name brain.js
11 silly mapToRegistry using default registry
12 silly mapToRegistry registry https://registry.npmjs.org/
13 silly mapToRegistry uri https://registry.npmjs.org/brain.js
14 verbose request uri https://registry.npmjs.org/brain.js
15 verbose request no auth needed
16 info attempt registry request try #1 at 21:59:12
17 verbose request id 74a22560d1b7c23a
18 verbose etag W/"9fb16e14a6b8c1d1ef1c110acba9db6b"
19 verbose lastModified Fri, 09 Aug 2019 11:09:50 GMT
20 http request GET https://registry.npmjs.org/brain.js
21 http 304 https://registry.npmjs.org/brain.js
22 verbose headers { date: 'Tue, 13 Aug 2019 16:29:14 GMT',
22 verbose headers   connection: 'keep-alive',
22 verbose headers   'set-cookie':
22 verbose headers    [ '__cfduid=d4bf1b2abca3b24131a1907349098099d1565713753; expires=Wed, 12-Aug-20 16:29:13 GMT; path=/; domain=.npmjs.org; HttpOnly' ],
22 verbose headers   'cf-cache-status': 'REVALIDATED',
22 verbose headers   'cache-control': 'max-age=300',
22 verbose headers   'cf-ray': '505c110c8bc58a5f-BOM',
22 verbose headers   etag: '"9fb16e14a6b8c1d1ef1c110acba9db6b"',
22 verbose headers   'expect-ct': 'max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"',
22 verbose headers   'last-modified': 'Fri, 09 Aug 2019 11:09:50 GMT',
22 verbose headers   vary: 'accept-encoding, accept',
22 verbose headers   'x-amz-meta-rev': '67-25f3ef5cf61222403c910fbd6b789aa9',
22 verbose headers   server: 'cloudflare' }
23 silly get cb [ 304,
23 silly get   { date: 'Tue, 13 Aug 2019 16:29:14 GMT',
23 silly get     connection: 'keep-alive',
23 silly get     'set-cookie':
23 silly get      [ '__cfduid=d4bf1b2abca3b24131a1907349098099d1565713753; expires=Wed, 12-Aug-20 16:29:13 GMT; path=/; domain=.npmjs.org; HttpOnly' ],
23 silly get     'cf-cache-status': 'REVALIDATED',
23 silly get     'cache-control': 'max-age=300',
23 silly get     'cf-ray': '505c110c8bc58a5f-BOM',
23 silly get     etag: '"9fb16e14a6b8c1d1ef1c110acba9db6b"',
23 silly get     'expect-ct': 'max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"',
23 silly get     'last-modified': 'Fri, 09 Aug 2019 11:09:50 GMT',
23 silly get     vary: 'accept-encoding, accept',
23 silly get     'x-amz-meta-rev': '67-25f3ef5cf61222403c910fbd6b789aa9',
23 silly get     server: 'cloudflare' } ]
24 verbose etag https://registry.npmjs.org/brain.js from cache
25 verbose get saving brain.js to /home/neel/.npm/registry.npmjs.org/brain.js/.cache.json
26 silly install normalizeTree
27 silly loadCurrentTree Finishing
28 silly loadIdealTree Starting
29 silly install loadIdealTree
30 silly cloneCurrentTree Starting
31 silly install cloneCurrentTreeToIdealTree
32 silly cloneCurrentTree Finishing
33 silly loadShrinkwrap Starting
34 silly install loadShrinkwrap
35 silly loadShrinkwrap Finishing
36 silly loadAllDepsIntoIdealTree Starting
37 silly install loadAllDepsIntoIdealTree
38 verbose stack Error: Missing required argument #1
38 verbose stack     at andLogAndFinish (/usr/share/npm/lib/fetch-package-metadata.js:31:3)
38 verbose stack     at fetchPackageMetadata (/usr/share/npm/lib/fetch-package-metadata.js:51:22)
38 verbose stack     at resolveWithNewModule (/usr/share/npm/lib/install/deps.js:456:12)
38 verbose stack     at /usr/share/npm/lib/install/deps.js:190:5
38 verbose stack     at /usr/share/npm/node_modules/slide/lib/async-map.js:52:35
38 verbose stack     at Array.forEach (<anonymous>)
38 verbose stack     at /usr/share/npm/node_modules/slide/lib/async-map.js:52:11
38 verbose stack     at Array.forEach (<anonymous>)
38 verbose stack     at asyncMap (/usr/share/npm/node_modules/slide/lib/async-map.js:51:8)
38 verbose stack     at exports.loadRequestedDeps (/usr/share/npm/lib/install/deps.js:188:3)
39 verbose cwd /home/neel/Documents/VS-Code_Projects
40 error Linux 5.0.0-23-generic
41 error argv "/usr/bin/node" "/usr/bin/npm" "install" "brain.js"
42 error node v8.10.0
43 error npm  v3.5.2
44 error code EMISSINGARG
45 error typeerror Error: Missing required argument #1
45 error typeerror     at andLogAndFinish (/usr/share/npm/lib/fetch-package-metadata.js:31:3)
45 error typeerror     at fetchPackageMetadata (/usr/share/npm/lib/fetch-package-metadata.js:51:22)
45 error typeerror     at resolveWithNewModule (/usr/share/npm/lib/install/deps.js:456:12)
45 error typeerror     at /usr/share/npm/lib/install/deps.js:190:5
45 error typeerror     at /usr/share/npm/node_modules/slide/lib/async-map.js:52:35
45 error typeerror     at Array.forEach (<anonymous>)
45 error typeerror     at /usr/share/npm/node_modules/slide/lib/async-map.js:52:11
45 error typeerror     at Array.forEach (<anonymous>)
45 error typeerror     at asyncMap (/usr/share/npm/node_modules/slide/lib/async-map.js:51:8)
45 error typeerror     at exports.loadRequestedDeps (/usr/share/npm/lib/install/deps.js:188:3)
46 error typeerror This is an error with npm itself. Please report this error at:
46 error typeerror     <http://github.com/npm/npm/issues>
47 verbose exit [ 1, true ]


Solution

  • npm ERR! npm  v3.5.2
    

    As discussed in the comments, this is an old version of NPM and the solution was to update to a newer version.