Every line of 'unable to locate package npm' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.
211 private async loadNpm(packageFile: string): Promise { 212 const prefix = path.dirname(packageFile); 213 let npm = await import('npm'); 214 await new Promise((resolve, reject) => { 215 npm.load({ json: true, save: false, 'save-dev': false, prefix: prefix }, (error, config) => { 216 if (error) { 217 reject(error); 218 } else { 219 resolve(config); 220 } 221 }); 222 }); 223 }
105 async function npmDeps(location) { 106 let pkgInfo = await fs.readFile(path.resolve(location, 'package.json')); 107 pkgInfo = parseJson(pkgInfo); 108 return pkgInfo.dependencies; 109 }
69 private getNpmPath() { 70 return new Promise((resolve, reject) => { 71 which('npm', (err, npmPath) => { 72 if (err && ! npmPath) { 73 if (this.app) { 74 this.app.logger.error(`npm -> path error: ${err}`); 75 } 76 reject(err); 77 } else { 78 if (this.app) { 79 this.app.logger.log(`npm -> path: ${npmPath}`); 80 } 81 resolve(npmPath); 82 } 83 }); 84 }); 85 }
12 function resolveFromNPM(pkg: string) { 13 try { 14 return require.resolve(pkg); 15 } catch { 16 return path.join('https://unpkg.com/', resolveSpectralVersion(pkg)); 17 } 18 }
34 checkNpm() { 35 try { 36 return require("npm"); 37 } catch (e) { 38 return false; 39 } 40 }
62 async getPackageMeta(packageName: string): Promise { 63 const result = cp.spawnSync("npm", ["show", "--json", packageName], { 64 encoding: "utf8" 65 }); 66 67 // $FlowFixMe(stdio-is-string) 68 return JSON.parse(result.stdout); 69 }
74 function npmLoad (context, fileUrl) { 75 return load(context, fileUrl) 76 ['catch'](function (ex) { 77 return npmTraverseUp(context, fileUrl); 78 }); 79 }
101 async install(cwd: string) { 102 const command = /^win/.test(process.platform) ? 'npm.cmd' : 'npm'; 103 const args = ['install']; 104 return await spawnProcess(command, args, { cwd, stdio: 'inherit' }); 105 }
10 determinePackageManager() { 11 if (this._packageManager) return this._packageManager; 12 13 let packageManager = this.project.packageManager; 14 15 if (!packageManager && fs.existsSync(path.resolve(process.cwd(), './yarn.lock'))) { 16 // Have to make best guess on yarn. 17 // If user is using yarn, then we use npm to install package, 18 // it will highly likely end in error. 19 packageManager = 'yarn'; 20 } 21 22 if (!packageManager) { 23 packageManager = 'npm'; 24 } 25 26 this._packageManager = packageManager; 27 return packageManager; 28 }
43 private static _getPackageVersion(packagePath: string): string { 44 const packageJSONPath = path.join(packagePath, 'package.json'); 45 const packageJSON = JSON.parse(fs.readFileSync(packageJSONPath).toString()); 46 const packageVersion = packageJSON.version; 47 return packageVersion; 48 }