Open zhfnjust opened 1 month ago
@parcel/resolver-default: External dependency "crypto" is not declared in package.json.
{ "name": "@scrypt/ssapp", "version": "1.0.0", "source": "src/index.js", "main": "dist/main.js", "module": "dist/module.js", "browser": "dist/browser.js", "types": "index.d.ts", "alias": { "process": "process/browser.js", "assert": "assert", "crypto": "crypto-browserify" }, "targets": { "types": false }, "scripts": { "watch": "parcel watch", "build": "parcel build --no-cache", "test": "echo \"Error: no test specified\" && exit 1" }, "keywords": [], "author": "", "license": "ISC", "description": "", "dependencies": { "assert": "^2.1.0", "crypto-browserify": "^3.12.0", "path-browserify": "^1.0.1", "process": "^0.11.10" }, "devDependencies": { "parcel": "^2.12.0" } }
Build success.
Build failed.
@parcel/core: Failed to resolve 'crypto' from './src/index.js'
C:\Users\myland\code\tmp\ssApp\src\index.js:2:28 1 | import { join } from "path";
2 | import { createHash } from 'crypto' | ^^^^^^^^ 3 | import { readFileSync } from 'fs' 4 | import assert from "assert";
C:\Users\myland\code\tmp\ssApp\package.json:26:3 25 | "description": "",
26 | "dependencies": { | ^^^^^^^^^^^^^^ 27 | "assert": "^2.1.0", 28 | "crypto-browserify": "^3.12.0",
💡 Add "crypto" as a dependency.
import { join } from "path"; import { createHash } from 'crypto' import { readFileSync } from 'fs' import assert from "assert"; export function add(a, b) { return a + b; } export function getaa() { return join("/asdfasdf/adfasdf", 'asdfas'); } export function myhash(str) { assert.deepEqual(str, "aa") console.log('myhash', str, process.env) console.log('aaa', readFileSync(join("aa", "aa.txt")).toString()) return createHash('sha256').update(str).digest('hex'); } export default { add, getaa, myhash }
this error only happened when i use parcel version >= v2.9.0
🐛 bug report
@parcel/resolver-default: External dependency "crypto" is not declared in package.json.
🎛 Configuration (.babelrc, package.json, cli command)
🤔 Expected Behavior
Build success.
😯 Current Behavior
Build failed.
@parcel/core: Failed to resolve 'crypto' from './src/index.js'
C:\Users\myland\code\tmp\ssApp\src\index.js:2:28 1 | import { join } from "path";
@parcel/resolver-default: External dependency "crypto" is not declared in package.json.
C:\Users\myland\code\tmp\ssApp\package.json:26:3 25 | "description": "",
💡 Add "crypto" as a dependency.
💁 Possible Solution
🔦 Context
💻 Code Sample
🌍 Your Environment