简体   繁体   中英

node.js npm package installation error: ENOENT: no such file or directory

In the c9.io IDE I'm attempting to install the faker npm package with node. I appear to have successfully installed the npm but encounter errors both when installing and running.

After hitting npm install faker it appears to have successfully installed but with errors:

└── faker@4.1.0 

npm WARN enoent ENOENT: no such file or directory, open '/home/ubuntu/workspace/IntroToNPM/MyShop/package.json'
npm WARN MyShop No description
npm WARN MyShop No repository field.
npm WARN MyShop No README data
npm WARN MyShop No license field.

However the node_modules directory is there and appears to have the package components. When I try to execute my .js file using the npm I get:

/home/ubuntu/workspace/IntroToNPM/MyShop/listProducts.js:3
var randomName = faker.name.findName(); // Rowan Nikolaus
                            ^

ReferenceError: faker is not defined
    at Object.<anonymous> (/home/ubuntu/workspace/IntroToNPM/MyShop/listProducts.js:3:29)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.runMain (module.js:604:10)
    at run (bootstrap_node.js:389:7)
    at startup (bootstrap_node.js:149:9)
    at bootstrap_node.js:504:3

I've read through troubleshooting and update-node-js-version-inside-cloud-9-ide , From what I read it seems to want me to roll back my version of node to be compatible with this npm package but that doesn't seem right.

I resolved this by deleting my work space and starting over. Not much of an 'answer' I know.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM