node.jsjspm

Cannot find module 'jspm'


Any ideas about the following errors?

   C:\PGM\_CODE\zui>npm install -g jspm
    C:\PGM\devel\node-v7.2.1-win-x64\jspm -> C:\PGM\devel\node-v7.2.1-win-x64\node_m
    odules\jspm\jspm.js
    C:\PGM\devel\node-v7.2.1-win-x64
    `-- jspm@0.16.53



C:\PGM\_CODE\zui>gulp watch
Index generation: 83.257ms
module.js:472
    throw err;
    ^

Error: Cannot find module 'jspm'
    at Function.Module._resolveFilename (module.js:470:15)
    at Function.Module._load (module.js:418:25)
    at Module.require (module.js:498:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (C:\PGM\_CODE\zui\build\tasks\export-release.js:7:14)

Solution

  • Well, funny enough I had this problem in 2017 and ran into it again in 2019.

    In 2019

    So this time, in order to fix it: I removed the JS extension, and set a new node_modules path.

    So in the command prompt I run:

    SET NODE_PATH=D:\Users\bakopme\AppData\Roaming\npm\node_modules
    

    And I changed the command to be:

    const jspm = require('jspm');
    

    Previously, in 2017

    I had hardcoded the path to the JS file. Obviously this isn't the right way to do it but I am mentioning it in case the other does not work.

    const jspm = require('/PGM/devel/node-v7.2.1-win-x64/node_modules/jspm/jspm.js');